DenseSubvector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_DENSESUBVECTOR_H_
36 #define _BLAZE_MATH_VIEWS_DENSESUBVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <stdexcept>
57 #include <blaze/math/Intrinsics.h>
58 #include <blaze/math/shims/Clear.h>
70 #include <blaze/system/CacheSize.h>
71 #include <blaze/system/Inline.h>
72 #include <blaze/system/Streaming.h>
75 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/mpl/If.h>
81 #include <blaze/util/mpl/Or.h>
82 #include <blaze/util/Template.h>
83 #include <blaze/util/Types.h>
88 
89 
90 namespace blaze {
91 
92 //=================================================================================================
93 //
94 // CLASS DEFINITION
95 //
96 //=================================================================================================
97 
98 //*************************************************************************************************
379 template< typename VT // Type of the dense vector
380  , bool AF = unaligned // Alignment flag
381  , bool TF = IsRowVector<VT>::value > // Transpose flag
382 class DenseSubvector : public DenseVector< DenseSubvector<VT,AF,TF>, TF >
383  , private Subvector
384 {
385  private:
386  //**Type definitions****************************************************************************
388  typedef typename If< IsExpression<VT>, VT, VT& >::Type Operand;
389 
392  //**********************************************************************************************
393 
394  //**********************************************************************************************
396 
402  enum { useConst = IsConst<VT>::value };
403  //**********************************************************************************************
404 
405  public:
406  //**Type definitions****************************************************************************
410  typedef typename VT::ElementType ElementType;
411  typedef typename IT::Type IntrinsicType;
412  typedef typename VT::ReturnType ReturnType;
413  typedef const DenseSubvector& CompositeType;
414 
417 
420 
422  typedef const ElementType* ConstPointer;
423 
426  //**********************************************************************************************
427 
428  //**SubvectorIterator class definition**********************************************************
431  template< typename IteratorType > // Type of the dense vector iterator
433  {
434  public:
435  //**Type definitions*************************************************************************
437  typedef typename std::iterator_traits<IteratorType>::iterator_category IteratorCategory;
438 
440  typedef typename std::iterator_traits<IteratorType>::value_type ValueType;
441 
443  typedef typename std::iterator_traits<IteratorType>::pointer PointerType;
444 
446  typedef typename std::iterator_traits<IteratorType>::reference ReferenceType;
447 
449  typedef typename std::iterator_traits<IteratorType>::difference_type DifferenceType;
450 
451  // STL iterator requirements
452  typedef IteratorCategory iterator_category;
453  typedef ValueType value_type;
454  typedef PointerType pointer;
455  typedef ReferenceType reference;
456  typedef DifferenceType difference_type;
457  //*******************************************************************************************
458 
459  //**Constructor******************************************************************************
463  : iterator_ ( ) // Iterator to the current subvector element
464  , final_ ( 0UL ) // The final iterator for intrinsic operations
465  , rest_ ( 0UL ) // The number of remaining elements beyond the final iterator
466  , isAligned_( false ) // Memory alignment flag
467  {}
468  //*******************************************************************************************
469 
470  //**Constructor******************************************************************************
478  inline SubvectorIterator( IteratorType iterator, IteratorType finalIterator,
479  size_t remainingElements, bool isMemoryAligned )
480  : iterator_ ( iterator ) // Iterator to the current subvector element
481  , final_ ( finalIterator ) // The final iterator for intrinsic operations
482  , rest_ ( remainingElements ) // The number of remaining elements beyond the final iterator
483  , isAligned_( isMemoryAligned ) // Memory alignment flag
484  {}
485  //*******************************************************************************************
486 
487  //**Constructor******************************************************************************
492  template< typename IteratorType2 >
494  : iterator_ ( it.base() ) // Iterator to the current subvector element
495  , final_ ( it.final() ) // The final iterator for intrinsic operations
496  , rest_ ( it.rest() ) // The number of remaining elements beyond the final iterator
497  , isAligned_( it.isAligned() ) // Memory alignment flag
498  {}
499  //*******************************************************************************************
500 
501  //**Addition assignment operator*************************************************************
507  inline SubvectorIterator& operator+=( size_t inc ) {
508  iterator_ += inc;
509  return *this;
510  }
511  //*******************************************************************************************
512 
513  //**Subtraction assignment operator**********************************************************
519  inline SubvectorIterator& operator-=( size_t dec ) {
520  iterator_ -= dec;
521  return *this;
522  }
523  //*******************************************************************************************
524 
525  //**Prefix increment operator****************************************************************
531  ++iterator_;
532  return *this;
533  }
534  //*******************************************************************************************
535 
536  //**Postfix increment operator***************************************************************
541  inline const SubvectorIterator operator++( int ) {
543  }
544  //*******************************************************************************************
545 
546  //**Prefix decrement operator****************************************************************
552  --iterator_;
553  return *this;
554  }
555  //*******************************************************************************************
556 
557  //**Postfix decrement operator***************************************************************
562  inline const SubvectorIterator operator--( int ) {
564  }
565  //*******************************************************************************************
566 
567  //**Element access operator******************************************************************
572  inline ReferenceType operator*() const {
573  return *iterator_;
574  }
575  //*******************************************************************************************
576 
577  //**Load function****************************************************************************
587  inline IntrinsicType load() const {
588  return loadu();
589  }
590  //*******************************************************************************************
591 
592  //**Loadu function***************************************************************************
602  inline IntrinsicType loadu() const {
603  if( isAligned_ ) {
604  return iterator_.load();
605  }
606  else if( iterator_ != final_ ) {
607  return iterator_.loadu();
608  }
609  else {
611  for( size_t i=0UL; i<rest_; ++i )
612  array[i] = *(iterator_+i);
613  for( size_t i=rest_; i<IT::size; ++i )
614  array[i] = ElementType();
615  return blaze::load( array.data() );
616  }
617  }
618  //*******************************************************************************************
619 
620  //**Equality operator************************************************************************
626  inline bool operator==( const SubvectorIterator& rhs ) const {
627  return iterator_ == rhs.iterator_;
628  }
629  //*******************************************************************************************
630 
631  //**Inequality operator**********************************************************************
637  inline bool operator!=( const SubvectorIterator& rhs ) const {
638  return iterator_ != rhs.iterator_;
639  }
640  //*******************************************************************************************
641 
642  //**Less-than operator***********************************************************************
648  inline bool operator<( const SubvectorIterator& rhs ) const {
649  return iterator_ < rhs.iterator_;
650  }
651  //*******************************************************************************************
652 
653  //**Greater-than operator********************************************************************
659  inline bool operator>( const SubvectorIterator& rhs ) const {
660  return iterator_ > rhs.iterator_;
661  }
662  //*******************************************************************************************
663 
664  //**Less-or-equal-than operator**************************************************************
670  inline bool operator<=( const SubvectorIterator& rhs ) const {
671  return iterator_ <= rhs.iterator_;
672  }
673  //*******************************************************************************************
674 
675  //**Greater-or-equal-than operator***********************************************************
681  inline bool operator>=( const SubvectorIterator& rhs ) const {
682  return iterator_ >= rhs.iterator_;
683  }
684  //*******************************************************************************************
685 
686  //**Subtraction operator*********************************************************************
692  inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
693  return iterator_ - rhs.iterator_;
694  }
695  //*******************************************************************************************
696 
697  //**Addition operator************************************************************************
704  friend inline const SubvectorIterator operator+( const SubvectorIterator& it, size_t inc ) {
705  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
706  }
707  //*******************************************************************************************
708 
709  //**Addition operator************************************************************************
716  friend inline const SubvectorIterator operator+( size_t inc, const SubvectorIterator& it ) {
717  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
718  }
719  //*******************************************************************************************
720 
721  //**Subtraction operator*********************************************************************
728  friend inline const SubvectorIterator operator-( const SubvectorIterator& it, size_t dec ) {
729  return SubvectorIterator( it.iterator_ - dec, it.final_, it.rest_, it.isAligned_ );
730  }
731  //*******************************************************************************************
732 
733  //**Base function****************************************************************************
738  inline IteratorType base() const {
739  return iterator_;
740  }
741  //*******************************************************************************************
742 
743  //**Final function***************************************************************************
748  inline IteratorType final() const {
749  return final_;
750  }
751  //*******************************************************************************************
752 
753  //**Rest function****************************************************************************
758  inline size_t rest() const {
759  return rest_;
760  }
761  //*******************************************************************************************
762 
763  //**IsAligned function***********************************************************************
768  inline bool isAligned() const {
769  return isAligned_;
770  }
771  //*******************************************************************************************
772 
773  private:
774  //**Member variables*************************************************************************
775  IteratorType iterator_;
776  IteratorType final_;
777  size_t rest_;
778  bool isAligned_;
779  //*******************************************************************************************
780  };
781  //**********************************************************************************************
782 
783  //**Type definitions****************************************************************************
786 
789  //**********************************************************************************************
790 
791  //**Compilation flags***************************************************************************
793  enum { vectorizable = VT::vectorizable };
794 
796  enum { smpAssignable = VT::smpAssignable };
797  //**********************************************************************************************
798 
799  //**Constructors********************************************************************************
802  explicit inline DenseSubvector( Operand vector, size_t index, size_t n );
803  // No explicitly declared copy constructor.
805  //**********************************************************************************************
806 
807  //**Destructor**********************************************************************************
808  // No explicitly declared destructor.
809  //**********************************************************************************************
810 
811  //**Data access functions***********************************************************************
814  inline Reference operator[]( size_t index );
815  inline ConstReference operator[]( size_t index ) const;
816  inline Pointer data ();
817  inline ConstPointer data () const;
818  inline Iterator begin ();
819  inline ConstIterator begin () const;
820  inline ConstIterator cbegin() const;
821  inline Iterator end ();
822  inline ConstIterator end () const;
823  inline ConstIterator cend () const;
825  //**********************************************************************************************
826 
827  //**Assignment operators************************************************************************
830  inline DenseSubvector& operator= ( const ElementType& rhs );
831  inline DenseSubvector& operator= ( const DenseSubvector& rhs );
832  template< typename VT2 > inline DenseSubvector& operator= ( const Vector<VT2,TF>& rhs );
833  template< typename VT2 > inline DenseSubvector& operator+=( const Vector<VT2,TF>& rhs );
834  template< typename VT2 > inline DenseSubvector& operator-=( const Vector<VT2,TF>& rhs );
835  template< typename VT2 > inline DenseSubvector& operator*=( const Vector<VT2,TF>& rhs );
836 
837  template< typename Other >
838  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
839  operator*=( Other rhs );
840 
841  template< typename Other >
842  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
843  operator/=( Other rhs );
845  //**********************************************************************************************
846 
847  //**Utility functions***************************************************************************
850  inline size_t size() const;
851  inline size_t capacity() const;
852  inline size_t nonZeros() const;
853  inline void reset();
854  template< typename Other > inline DenseSubvector& scale( const Other& scalar );
856  //**********************************************************************************************
857 
858  private:
859  //**********************************************************************************************
861  template< typename VT2 >
863  struct VectorizedAssign {
864  enum { value = vectorizable && VT2::vectorizable &&
865  IsSame<ElementType,typename VT2::ElementType>::value };
866  };
868  //**********************************************************************************************
869 
870  //**********************************************************************************************
872  template< typename VT2 >
874  struct VectorizedAddAssign {
875  enum { value = vectorizable && VT2::vectorizable &&
876  IsSame<ElementType,typename VT2::ElementType>::value &&
877  IntrinsicTrait<ElementType>::addition };
878  };
880  //**********************************************************************************************
881 
882  //**********************************************************************************************
884  template< typename VT2 >
886  struct VectorizedSubAssign {
887  enum { value = vectorizable && VT2::vectorizable &&
888  IsSame<ElementType,typename VT2::ElementType>::value &&
889  IntrinsicTrait<ElementType>::subtraction };
890  };
892  //**********************************************************************************************
893 
894  //**********************************************************************************************
896  template< typename VT2 >
898  struct VectorizedMultAssign {
899  enum { value = vectorizable && VT2::vectorizable &&
900  IsSame<ElementType,typename VT2::ElementType>::value &&
901  IntrinsicTrait<ElementType>::multiplication };
902  };
904  //**********************************************************************************************
905 
906  public:
907  //**Expression template evaluation functions****************************************************
910  template< typename Other >
911  inline bool canAlias( const Other* alias ) const;
912 
913  template< typename VT2, bool AF2, bool TF2 >
914  inline bool canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
915 
916  template< typename Other >
917  inline bool isAliased( const Other* alias ) const;
918 
919  template< typename VT2, bool AF2, bool TF2 >
920  inline bool isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
921 
922  inline bool isAligned () const;
923  inline bool canSMPAssign() const;
924 
925  inline IntrinsicType load ( size_t index ) const;
926  inline IntrinsicType loadu( size_t index ) const;
927 
928  inline void store ( size_t index, const IntrinsicType& value );
929  inline void storeu( size_t index, const IntrinsicType& value );
930  inline void stream( size_t index, const IntrinsicType& value );
931 
932  template< typename VT2 >
933  inline typename DisableIf< VectorizedAssign<VT2> >::Type
934  assign( const DenseVector <VT2,TF>& rhs );
935 
936  template< typename VT2 >
937  inline typename EnableIf< VectorizedAssign<VT2> >::Type
938  assign( const DenseVector <VT2,TF>& rhs );
939 
940  template< typename VT2 > inline void assign( const SparseVector<VT2,TF>& rhs );
941 
942  template< typename VT2 >
943  inline typename DisableIf< VectorizedAddAssign<VT2> >::Type
944  addAssign( const DenseVector <VT2,TF>& rhs );
945 
946  template< typename VT2 >
947  inline typename EnableIf< VectorizedAddAssign<VT2> >::Type
948  addAssign ( const DenseVector <VT2,TF>& rhs );
949 
950  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
951 
952  template< typename VT2 >
953  inline typename DisableIf< VectorizedSubAssign<VT2> >::Type
954  subAssign ( const DenseVector <VT2,TF>& rhs );
955 
956  template< typename VT2 >
957  inline typename EnableIf< VectorizedSubAssign<VT2> >::Type
958  subAssign( const DenseVector <VT2,TF>& rhs );
959 
960  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
961 
962  template< typename VT2 >
963  inline typename DisableIf< VectorizedMultAssign<VT2> >::Type
964  multAssign( const DenseVector <VT2,TF>& rhs );
965 
966  template< typename VT2 >
967  inline typename EnableIf< VectorizedMultAssign<VT2> >::Type
968  multAssign( const DenseVector <VT2,TF>& rhs );
969 
970  template< typename VT2 > inline void multAssign( const SparseVector<VT2,TF>& rhs );
972  //**********************************************************************************************
973 
974  private:
975  //**Member variables****************************************************************************
978  Operand vector_;
979  const size_t offset_;
980  const size_t size_;
981  const size_t rest_;
982  const size_t final_;
983 
987  const bool isAligned_;
988 
998  //**********************************************************************************************
999 
1000  //**Friend declarations*************************************************************************
1002  template< typename VT2, bool AF2, bool TF2 > friend class DenseSubvector;
1003 
1004  template< bool AF1, typename VT2, bool AF2, bool TF2 >
1005  friend const DenseSubvector<VT2,AF1,TF2>
1006  subvector( const DenseSubvector<VT2,AF2,TF2>& dv, size_t index, size_t size );
1007 
1008  template< typename VT2, bool AF2, bool TF2 >
1009  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseVector<VT2,TF2>& b );
1010 
1011  template< typename VT2, bool AF2, bool TF2 >
1012  friend bool isSame( const DenseVector<VT2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
1013 
1014  template< typename VT2, bool AF2, bool TF2 >
1015  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
1016 
1017  template< typename VT2, bool AF2, bool TF2 >
1018  friend typename DerestrictTrait< DenseSubvector<VT2,AF2,TF2> >::Type
1019  derestrict( DenseSubvector<VT2,AF2,TF2>& dv );
1021  //**********************************************************************************************
1022 
1023  //**Compile time checks*************************************************************************
1031  //**********************************************************************************************
1032 };
1033 //*************************************************************************************************
1034 
1035 
1036 
1037 
1038 //=================================================================================================
1039 //
1040 // CONSTRUCTOR
1041 //
1042 //=================================================================================================
1043 
1044 //*************************************************************************************************
1056 template< typename VT // Type of the dense vector
1057  , bool AF // Alignment flag
1058  , bool TF > // Transpose flag
1059 inline DenseSubvector<VT,AF,TF>::DenseSubvector( Operand vector, size_t index, size_t n )
1060  : vector_ ( vector ) // The vector containing the subvector
1061  , offset_ ( index ) // The offset of the subvector within the dense vector
1062  , size_ ( n ) // The size of the subvector
1063  , rest_ ( n % IT::size ) // The number of remaining elements in an unaligned intrinsic operation
1064  , final_ ( n - rest_ ) // The final index for unaligned intrinsic operations
1065  , isAligned_( ( index % IT::size == 0UL ) &&
1066  ( index + n == vector.size() || n % IT::size == 0UL ) )
1067 {
1068  if( index + n > vector.size() )
1069  throw std::invalid_argument( "Invalid subvector specification" );
1070 }
1071 //*************************************************************************************************
1072 
1073 
1074 
1075 
1076 //=================================================================================================
1077 //
1078 // DATA ACCESS FUNCTIONS
1079 //
1080 //=================================================================================================
1081 
1082 //*************************************************************************************************
1088 template< typename VT // Type of the dense vector
1089  , bool AF // Alignment flag
1090  , bool TF > // Transpose flag
1093 {
1094  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
1095  return vector_[offset_+index];
1096 }
1097 //*************************************************************************************************
1098 
1099 
1100 //*************************************************************************************************
1106 template< typename VT // Type of the dense vector
1107  , bool AF // Alignment flag
1108  , bool TF > // Transpose flag
1111 {
1112  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
1113  return const_cast<const VT&>( vector_ )[offset_+index];
1114 }
1115 //*************************************************************************************************
1116 
1117 
1118 //*************************************************************************************************
1125 template< typename VT // Type of the dense vector
1126  , bool AF // Alignment flag
1127  , bool TF > // Transpose flag
1129 {
1130  return vector_.data() + offset_;
1131 }
1132 //*************************************************************************************************
1133 
1134 
1135 //*************************************************************************************************
1142 template< typename VT // Type of the dense vector
1143  , bool AF // Alignment flag
1144  , bool TF > // Transpose flag
1146 {
1147  return vector_.data() + offset_;
1148 }
1149 //*************************************************************************************************
1150 
1151 
1152 //*************************************************************************************************
1159 template< typename VT // Type of the dense vector
1160  , bool AF // Alignment flag
1161  , bool TF > // Transpose flag
1163 {
1164  const typename VT::Iterator first( vector_.begin() + offset_ );
1165  return Iterator( first, first + final_, rest_, isAligned_ );
1166 }
1167 //*************************************************************************************************
1168 
1169 
1170 //*************************************************************************************************
1177 template< typename VT // Type of the dense vector
1178  , bool AF // Alignment flag
1179  , bool TF > // Transpose flag
1181 {
1182  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
1183  return ConstIterator( first, first + final_, rest_, isAligned_ );
1184 }
1185 //*************************************************************************************************
1186 
1187 
1188 //*************************************************************************************************
1195 template< typename VT // Type of the dense vector
1196  , bool AF // Alignment flag
1197  , bool TF > // Transpose flag
1199 {
1200  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
1201  return ConstIterator( first, first + final_, rest_, isAligned_ );
1202 }
1203 //*************************************************************************************************
1204 
1205 
1206 //*************************************************************************************************
1213 template< typename VT // Type of the dense vector
1214  , bool AF // Alignment flag
1215  , bool TF > // Transpose flag
1217 {
1218  const typename VT::Iterator last( vector_.begin() + offset_ + size_ );
1219  return Iterator( last, last, rest_, isAligned_ );
1220 }
1221 //*************************************************************************************************
1222 
1223 
1224 //*************************************************************************************************
1231 template< typename VT // Type of the dense vector
1232  , bool AF // Alignment flag
1233  , bool TF > // Transpose flag
1235 {
1236  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1237  return ConstIterator( last, last, rest_, isAligned_ );
1238 }
1239 //*************************************************************************************************
1240 
1241 
1242 //*************************************************************************************************
1249 template< typename VT // Type of the dense vector
1250  , bool AF // Alignment flag
1251  , bool TF > // Transpose flag
1253 {
1254  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1255  return ConstIterator( last, last, rest_, isAligned_ );
1256 }
1257 //*************************************************************************************************
1258 
1259 
1260 
1261 
1262 //=================================================================================================
1263 //
1264 // ASSIGNMENT OPERATORS
1265 //
1266 //=================================================================================================
1267 
1268 //*************************************************************************************************
1274 template< typename VT // Type of the dense vector
1275  , bool AF // Alignment flag
1276  , bool TF > // Transpose flag
1278 {
1279  const size_t iend( offset_ + size_ );
1280 
1281  for( size_t i=offset_; i<iend; ++i )
1282  vector_[i] = rhs;
1283 
1284  return *this;
1285 }
1286 //*************************************************************************************************
1287 
1288 
1289 //*************************************************************************************************
1299 template< typename VT // Type of the dense vector
1300  , bool AF // Alignment flag
1301  , bool TF > // Transpose flag
1303 {
1306 
1307  if( &rhs == this || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
1308  return *this;
1309 
1310  if( size() != rhs.size() )
1311  throw std::invalid_argument( "Subvector sizes do not match" );
1312 
1313  if( rhs.canAlias( &vector_ ) ) {
1314  const ResultType tmp( ~rhs );
1315  smpAssign( *this, tmp );
1316  }
1317  else {
1318  smpAssign( *this, rhs );
1319  }
1320 
1321  return *this;
1322 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1336 template< typename VT // Type of the dense vector
1337  , bool AF // Alignment flag
1338  , bool TF > // Transpose flag
1339 template< typename VT2 > // Type of the right-hand side vector
1341 {
1344 
1345  if( size() != (~rhs).size() )
1346  throw std::invalid_argument( "Vector sizes do not match" );
1347 
1348  if( (~rhs).canAlias( &vector_ ) ) {
1349  const typename VT2::ResultType tmp( ~rhs );
1350  smpAssign( *this, tmp );
1351  }
1352  else {
1354  reset();
1355  smpAssign( *this, ~rhs );
1356  }
1357 
1358  return *this;
1359 }
1360 //*************************************************************************************************
1361 
1362 
1363 //*************************************************************************************************
1373 template< typename VT // Type of the dense vector
1374  , bool AF // Alignment flag
1375  , bool TF > // Transpose flag
1376 template< typename VT2 > // Type of the right-hand side vector
1378 {
1381 
1382  if( size() != (~rhs).size() )
1383  throw std::invalid_argument( "Vector sizes do not match" );
1384 
1385  if( (~rhs).canAlias( &vector_ ) ) {
1386  const typename VT2::ResultType tmp( ~rhs );
1387  smpAddAssign( *this, tmp );
1388  }
1389  else {
1390  smpAddAssign( *this, ~rhs );
1391  }
1392 
1393  return *this;
1394 }
1395 //*************************************************************************************************
1396 
1397 
1398 //*************************************************************************************************
1408 template< typename VT // Type of the dense vector
1409  , bool AF // Alignment flag
1410  , bool TF > // Transpose flag
1411 template< typename VT2 > // Type of the right-hand side vector
1413 {
1416 
1417  if( size() != (~rhs).size() )
1418  throw std::invalid_argument( "Vector sizes do not match" );
1419 
1420  if( (~rhs).canAlias( &vector_ ) ) {
1421  const typename VT2::ResultType tmp( ~rhs );
1422  smpSubAssign( *this, tmp );
1423  }
1424  else {
1425  smpSubAssign( *this, ~rhs );
1426  }
1427 
1428  return *this;
1429 }
1430 //*************************************************************************************************
1431 
1432 
1433 //*************************************************************************************************
1444 template< typename VT // Type of the dense vector
1445  , bool AF // Alignment flag
1446  , bool TF > // Transpose flag
1447 template< typename VT2 > // Type of the right-hand side vector
1449 {
1452 
1453  if( size() != (~rhs).size() )
1454  throw std::invalid_argument( "Vector sizes do not match" );
1455 
1456  if( (~rhs).canAlias( &vector_ ) || IsSparseVector<VT2>::value ) {
1457  const ResultType tmp( *this * (~rhs) );
1458  smpAssign( *this, tmp );
1459  }
1460  else {
1461  smpMultAssign( *this, ~rhs );
1462  }
1463 
1464  return *this;
1465 }
1466 //*************************************************************************************************
1467 
1468 
1469 //*************************************************************************************************
1476 template< typename VT // Type of the dense vector
1477  , bool AF // Alignment flag
1478  , bool TF > // Transpose flag
1479 template< typename Other > // Data type of the right-hand side scalar
1480 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,AF,TF> >::Type&
1482 {
1483  smpAssign( *this, (*this) * rhs );
1484  return *this;
1485 }
1486 //*************************************************************************************************
1487 
1488 
1489 //*************************************************************************************************
1498 template< typename VT // Type of the dense vector
1499  , bool AF // Alignment flag
1500  , bool TF > // Transpose flag
1501 template< typename Other > // Data type of the right-hand side scalar
1502 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,AF,TF> >::Type&
1504 {
1505  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1506 
1507  smpAssign( *this, (*this) / rhs );
1508  return *this;
1509 }
1510 //*************************************************************************************************
1511 
1512 
1513 
1514 
1515 //=================================================================================================
1516 //
1517 // UTILITY FUNCTIONS
1518 //
1519 //=================================================================================================
1520 
1521 //*************************************************************************************************
1526 template< typename VT // Type of the dense vector
1527  , bool AF // Alignment flag
1528  , bool TF > // Transpose flag
1529 inline size_t DenseSubvector<VT,AF,TF>::size() const
1530 {
1531  return size_;
1532 }
1533 //*************************************************************************************************
1534 
1535 
1536 //*************************************************************************************************
1541 template< typename VT // Type of the dense vector
1542  , bool AF // Alignment flag
1543  , bool TF > // Transpose flag
1545 {
1546  return vector_.capacity() - offset_;
1547 }
1548 //*************************************************************************************************
1549 
1550 
1551 //*************************************************************************************************
1559 template< typename VT // Type of the dense vector
1560  , bool AF // Alignment flag
1561  , bool TF > // Transpose flag
1563 {
1564  size_t nonzeros( 0 );
1565 
1566  const size_t iend( offset_ + size_ );
1567  for( size_t i=offset_; i<iend; ++i ) {
1568  if( !isDefault( vector_[i] ) )
1569  ++nonzeros;
1570  }
1571 
1572  return nonzeros;
1573 }
1574 //*************************************************************************************************
1575 
1576 
1577 //*************************************************************************************************
1582 template< typename VT // Type of the dense vector
1583  , bool AF // Alignment flag
1584  , bool TF > // Transpose flag
1586 {
1587  using blaze::clear;
1588 
1589  const size_t iend( offset_ + size_ );
1590  for( size_t i=offset_; i<iend; ++i )
1591  clear( vector_[i] );
1592 }
1593 //*************************************************************************************************
1594 
1595 
1596 //*************************************************************************************************
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 scalar value
1607 {
1608  const size_t iend( offset_ + size_ );
1609  for( size_t i=offset_; i<iend; ++i )
1610  vector_[i] *= scalar;
1611  return *this;
1612 }
1613 //*************************************************************************************************
1614 
1615 
1616 
1617 
1618 //=================================================================================================
1619 //
1620 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1621 //
1622 //=================================================================================================
1623 
1624 //*************************************************************************************************
1634 template< typename VT // Type of the dense vector
1635  , bool AF // Alignment flag
1636  , bool TF > // Transpose flag
1637 template< typename Other > // Data type of the foreign expression
1638 inline bool DenseSubvector<VT,AF,TF>::canAlias( const Other* alias ) const
1639 {
1640  return vector_.isAliased( alias );
1641 }
1642 //*************************************************************************************************
1643 
1644 
1645 //*************************************************************************************************
1655 template< typename VT // Type of the dense vector
1656  , bool AF // Alignment flag
1657  , bool TF > // Transpose flag
1658 template< typename VT2 // Data type of the foreign dense subvector
1659  , bool AF2 // Alignment flag of the foreign dense subvector
1660  , bool TF2 > // Transpose flag of the foreign dense subvector
1662 {
1663  return ( vector_.isAliased( &alias->vector_ ) &&
1664  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
1665 }
1666 //*************************************************************************************************
1667 
1668 
1669 //*************************************************************************************************
1679 template< typename VT // Type of the dense vector
1680  , bool AF // Alignment flag
1681  , bool TF > // Transpose flag
1682 template< typename Other > // Data type of the foreign expression
1683 inline bool DenseSubvector<VT,AF,TF>::isAliased( const Other* alias ) const
1684 {
1685  return vector_.isAliased( alias );
1686 }
1687 //*************************************************************************************************
1688 
1689 
1690 //*************************************************************************************************
1700 template< typename VT // Type of the dense vector
1701  , bool AF // Alignment flag
1702  , bool TF > // Transpose flag
1703 template< typename VT2 // Data type of the foreign dense subvector
1704  , bool AF2 // Alignment flag of the foreign dense subvector
1705  , bool TF2 > // Transpose flag of the foreign dense subvector
1707 {
1708  return ( vector_.isAliased( &alias->vector_ ) &&
1709  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
1710 }
1711 //*************************************************************************************************
1712 
1713 
1714 //*************************************************************************************************
1723 template< typename VT // Type of the dense vector
1724  , bool AF // Alignment flag
1725  , bool TF > // Transpose flag
1727 {
1728  return isAligned_;
1729 }
1730 //*************************************************************************************************
1731 
1732 
1733 //*************************************************************************************************
1743 template< typename VT // Type of the dense vector
1744  , bool AF // Alignment flag
1745  , bool TF > // Transpose flag
1747 {
1748  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1749 }
1750 //*************************************************************************************************
1751 
1752 
1753 //*************************************************************************************************
1766 template< typename VT // Type of the dense vector
1767  , bool AF // Alignment flag
1768  , bool TF > // Transpose flag
1770  DenseSubvector<VT,AF,TF>::load( size_t index ) const
1771 {
1772  return loadu( index );
1773 }
1774 //*************************************************************************************************
1775 
1776 
1777 //*************************************************************************************************
1790 template< typename VT // Type of the dense vector
1791  , bool AF // Alignment flag
1792  , bool TF > // Transpose flag
1794  DenseSubvector<VT,AF,TF>::loadu( size_t index ) const
1795 {
1796  using blaze::load;
1797 
1799 
1800  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1801  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1802 
1803  if( isAligned_ ) {
1804  return vector_.load( offset_+index );
1805  }
1806  else if( index != final_ ) {
1807  return vector_.loadu( offset_+index );
1808  }
1809  else {
1811  for( size_t i=0UL; i<rest_; ++i )
1812  array[i] = vector_[offset_+index+i];
1813  for( size_t i=rest_; i<IT::size; ++i )
1814  array[i] = ElementType();
1815  return load( array.data() );
1816  }
1817 }
1818 //*************************************************************************************************
1819 
1820 
1821 //*************************************************************************************************
1835 template< typename VT // Type of the dense vector
1836  , bool AF // Alignment flag
1837  , bool TF > // Transpose flag
1838 inline void DenseSubvector<VT,AF,TF>::store( size_t index, const IntrinsicType& value )
1839 {
1840  storeu( index, value );
1841 }
1842 //*************************************************************************************************
1843 
1844 
1845 //*************************************************************************************************
1859 template< typename VT // Type of the dense vector
1860  , bool AF // Alignment flag
1861  , bool TF > // Transpose flag
1862 inline void DenseSubvector<VT,AF,TF>::storeu( size_t index, const IntrinsicType& value )
1863 {
1864  using blaze::store;
1865 
1867 
1868  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1869  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1870 
1871  if( isAligned_ ) {
1872  vector_.store( offset_+index, value );
1873  }
1874  else if( index != final_ ) {
1875  vector_.storeu( offset_+index, value );
1876  }
1877  else {
1879  store( array.data(), value );
1880  for( size_t i=0UL; i<rest_; ++i )
1881  vector_[offset_+index+i] = array[i];
1882  }
1883 }
1884 //*************************************************************************************************
1885 
1886 
1887 //*************************************************************************************************
1901 template< typename VT // Type of the dense vector
1902  , bool AF // Alignment flag
1903  , bool TF > // Transpose flag
1904 inline void DenseSubvector<VT,AF,TF>::stream( size_t index, const IntrinsicType& value )
1905 {
1906  storeu( index, value );
1907 }
1908 //*************************************************************************************************
1909 
1910 
1911 //*************************************************************************************************
1922 template< typename VT // Type of the dense vector
1923  , bool AF // Alignment flag
1924  , bool TF > // Transpose flag
1925 template< typename VT2 > // Type of the right-hand side dense vector
1926 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1928 {
1929  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1930 
1931  const size_t ipos( size() & size_t(-2) );
1932  for( size_t i=0UL; i<ipos; i+=2UL ) {
1933  vector_[i+offset_ ] = (~rhs)[i ];
1934  vector_[i+offset_+1UL] = (~rhs)[i+1UL];
1935  }
1936  if( ipos < size() ) {
1937  vector_[ipos+offset_] = (~rhs)[ipos];
1938  }
1939 }
1940 //*************************************************************************************************
1941 
1942 
1943 //*************************************************************************************************
1954 template< typename VT // Type of the dense vector
1955  , bool AF // Alignment flag
1956  , bool TF > // Transpose flag
1957 template< typename VT2 > // Type of the right-hand side dense vector
1958 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1960 {
1961  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1962 
1964 
1965  if( useStreaming && isAligned_ &&
1966  ( size_ > ( cacheSize/( sizeof(ElementType) * 3UL ) ) ) &&
1967  !(~rhs).isAliased( &vector_ ) )
1968  {
1969  for( size_t i=0UL; i<size(); i+=IT::size ) {
1970  vector_.stream( offset_+i, (~rhs).load(i) );
1971  }
1972  }
1973  else
1974  {
1975  const size_t ipos( size_ & size_t(-IT::size*4) );
1976  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
1977 
1978  typename VT2::ConstIterator it( (~rhs).begin() );
1979  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
1980  vector_.storeu( offset_+i , it.load() ); it += IT::size;
1981  vector_.storeu( offset_+i+IT::size , it.load() ); it += IT::size;
1982  vector_.storeu( offset_+i+IT::size*2UL, it.load() ); it += IT::size;
1983  vector_.storeu( offset_+i+IT::size*3UL, it.load() ); it += IT::size;
1984  }
1985  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
1986  storeu( i, it.load() );
1987  }
1988  }
1989 }
1990 //*************************************************************************************************
1991 
1992 
1993 //*************************************************************************************************
2004 template< typename VT // Type of the dense vector
2005  , bool AF // Alignment flag
2006  , bool TF > // Transpose flag
2007 template< typename VT2 > // Type of the right-hand side dense vector
2009 {
2010  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2011 
2012  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2013  vector_[element->index()+offset_] = element->value();
2014 }
2015 //*************************************************************************************************
2016 
2017 
2018 //*************************************************************************************************
2029 template< typename VT // Type of the dense vector
2030  , bool AF // Alignment flag
2031  , bool TF > // Transpose flag
2032 template< typename VT2 > // Type of the right-hand side dense vector
2033 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
2035 {
2036  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2037 
2038  const size_t ipos( size() & size_t(-2) );
2039  for( size_t i=0UL; i<ipos; i+=2UL ) {
2040  vector_[i+offset_ ] += (~rhs)[i ];
2041  vector_[i+offset_+1UL] += (~rhs)[i+1UL];
2042  }
2043  if( ipos < size() ) {
2044  vector_[ipos+offset_] += (~rhs)[ipos];
2045  }
2046 }
2047 //*************************************************************************************************
2048 
2049 
2050 //*************************************************************************************************
2061 template< typename VT // Type of the dense vector
2062  , bool AF // Alignment flag
2063  , bool TF > // Transpose flag
2064 template< typename VT2 > // Type of the right-hand side dense vector
2065 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
2067 {
2068  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2069 
2071 
2072  const size_t ipos( size_ & size_t(-IT::size*4) );
2073  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
2074 
2075  typename VT2::ConstIterator it( (~rhs).begin() );
2076  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
2077  vector_.storeu( offset_+i , load(i ) + it.load() ); it += IT::size;
2078  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) + it.load() ); it += IT::size;
2079  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) + it.load() ); it += IT::size;
2080  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) + it.load() ); it += IT::size;
2081  }
2082  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
2083  storeu( i, load(i) + it.load() );
2084  }
2085 }
2086 //*************************************************************************************************
2087 
2088 
2089 //*************************************************************************************************
2100 template< typename VT // Type of the dense vector
2101  , bool AF // Alignment flag
2102  , bool TF > // Transpose flag
2103 template< typename VT2 > // Type of the right-hand side dense vector
2105 {
2106  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2107 
2108  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2109  vector_[element->index()+offset_] += element->value();
2110 }
2111 //*************************************************************************************************
2112 
2113 
2114 //*************************************************************************************************
2125 template< typename VT // Type of the dense vector
2126  , bool AF // Alignment flag
2127  , bool TF > // Transpose flag
2128 template< typename VT2 > // Type of the right-hand side dense vector
2129 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
2131 {
2132  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2133 
2134  const size_t ipos( size() & size_t(-2) );
2135  for( size_t i=0UL; i<ipos; i+=2UL ) {
2136  vector_[i+offset_ ] -= (~rhs)[i ];
2137  vector_[i+offset_+1UL] -= (~rhs)[i+1UL];
2138  }
2139  if( ipos < size() ) {
2140  vector_[ipos+offset_] -= (~rhs)[ipos];
2141  }
2142 }
2143 //*************************************************************************************************
2144 
2145 
2146 //*************************************************************************************************
2157 template< typename VT // Type of the dense vector
2158  , bool AF // Alignment flag
2159  , bool TF > // Transpose flag
2160 template< typename VT2 > // Type of the right-hand side dense vector
2161 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
2163 {
2164  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2165 
2167 
2168  const size_t ipos( size_ & size_t(-IT::size*4) );
2169  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
2170 
2171  typename VT2::ConstIterator it( (~rhs).begin() );
2172  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
2173  vector_.storeu( offset_+i , load(i ) - it.load() ); it += IT::size;
2174  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) - it.load() ); it += IT::size;
2175  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) - it.load() ); it += IT::size;
2176  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) - it.load() ); it += IT::size;
2177  }
2178  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
2179  storeu( i, load(i) - it.load() );
2180  }
2181 }
2182 //*************************************************************************************************
2183 
2184 
2185 //*************************************************************************************************
2196 template< typename VT // Type of the dense vector
2197  , bool AF // Alignment flag
2198  , bool TF > // Transpose flag
2199 template< typename VT2 > // Type of the right-hand side dense vector
2201 {
2202  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2203 
2204  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2205  vector_[element->index()+offset_] -= element->value();
2206 }
2207 //*************************************************************************************************
2208 
2209 
2210 //*************************************************************************************************
2221 template< typename VT // Type of the dense vector
2222  , bool AF // Alignment flag
2223  , bool TF > // Transpose flag
2224 template< typename VT2 > // Type of the right-hand side dense vector
2225 inline typename DisableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
2227 {
2228  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2229 
2230  const size_t ipos( size() & size_t(-2) );
2231  for( size_t i=0UL; i<ipos; i+=2UL ) {
2232  vector_[i+offset_ ] *= (~rhs)[i ];
2233  vector_[i+offset_+1UL] *= (~rhs)[i+1UL];
2234  }
2235  if( ipos < size() ) {
2236  vector_[ipos+offset_] *= (~rhs)[ipos];
2237  }
2238 }
2239 //*************************************************************************************************
2240 
2241 
2242 //*************************************************************************************************
2253 template< typename VT // Type of the dense vector
2254  , bool AF // Alignment flag
2255  , bool TF > // Transpose flag
2256 template< typename VT2 > // Type of the right-hand side dense vector
2257 inline typename EnableIf< typename DenseSubvector<VT,AF,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
2259 {
2260  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2261 
2263 
2264  const size_t ipos( size_ & size_t(-IT::size*4) );
2265  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
2266 
2267  typename VT2::ConstIterator it( (~rhs).begin() );
2268  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
2269  vector_.storeu( offset_+i , load(i ) * it.load() ); it += IT::size;
2270  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) * it.load() ); it += IT::size;
2271  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) * it.load() ); it += IT::size;
2272  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) * it.load() ); it += IT::size;
2273  }
2274  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
2275  storeu( i, load(i) * it.load() );
2276  }
2277 }
2278 //*************************************************************************************************
2279 
2280 
2281 //*************************************************************************************************
2292 template< typename VT // Type of the dense vector
2293  , bool AF // Alignment flag
2294  , bool TF > // Transpose flag
2295 template< typename VT2 > // Type of the right-hand side dense vector
2297 {
2298  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2299 
2300  const ResultType tmp( serial( *this ) );
2301 
2302  reset();
2303 
2304  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2305  vector_[element->index()+offset_] = tmp[element->index()] * element->value();
2306 }
2307 //*************************************************************************************************
2308 
2309 
2310 
2311 
2312 
2313 
2314 
2315 
2316 //=================================================================================================
2317 //
2318 // CLASS TEMPLATE SPECIALIZATION FOR ALIGNED SUBVECTORS
2319 //
2320 //=================================================================================================
2321 
2322 //*************************************************************************************************
2330 template< typename VT // Type of the dense vector
2331  , bool TF > // Transpose flag
2332 class DenseSubvector<VT,aligned,TF> : public DenseVector< DenseSubvector<VT,aligned,TF>, TF >
2333  , private Subvector
2334 {
2335  private:
2336  //**Type definitions****************************************************************************
2338  typedef typename If< IsExpression<VT>, VT, VT& >::Type Operand;
2339 
2342  //**********************************************************************************************
2343 
2344  //**********************************************************************************************
2346 
2352  enum { useConst = IsConst<VT>::value };
2353  //**********************************************************************************************
2354 
2355  public:
2356  //**Type definitions****************************************************************************
2357  typedef DenseSubvector<VT,aligned,TF> This;
2358  typedef typename SubvectorTrait<VT>::Type ResultType;
2359  typedef typename ResultType::TransposeType TransposeType;
2360  typedef typename VT::ElementType ElementType;
2361  typedef typename IT::Type IntrinsicType;
2362  typedef typename VT::ReturnType ReturnType;
2363  typedef const DenseSubvector& CompositeType;
2364 
2366  typedef typename VT::ConstReference ConstReference;
2367 
2369  typedef typename IfTrue< useConst, ConstReference, typename VT::Reference >::Type Reference;
2370 
2372  typedef const ElementType* ConstPointer;
2373 
2375  typedef typename IfTrue< useConst, ConstPointer, ElementType* >::Type Pointer;
2376 
2378  typedef typename VT::ConstIterator ConstIterator;
2379 
2381  typedef typename IfTrue< useConst, ConstIterator, typename VT::Iterator >::Type Iterator;
2382  //**********************************************************************************************
2383 
2384  //**Compilation flags***************************************************************************
2386  enum { vectorizable = VT::vectorizable };
2387 
2389  enum { smpAssignable = VT::smpAssignable };
2390  //**********************************************************************************************
2391 
2392  //**Constructors********************************************************************************
2395  explicit inline DenseSubvector( Operand vector, size_t index, size_t n );
2396  // No explicitly declared copy constructor.
2398  //**********************************************************************************************
2399 
2400  //**Destructor**********************************************************************************
2401  // No explicitly declared destructor.
2402  //**********************************************************************************************
2403 
2404  //**Data access functions***********************************************************************
2407  inline Reference operator[]( size_t index );
2408  inline ConstReference operator[]( size_t index ) const;
2409  inline Pointer data ();
2410  inline ConstPointer data () const;
2411  inline Iterator begin ();
2412  inline ConstIterator begin () const;
2413  inline ConstIterator cbegin() const;
2414  inline Iterator end ();
2415  inline ConstIterator end () const;
2416  inline ConstIterator cend () const;
2418  //**********************************************************************************************
2419 
2420  //**Assignment operators************************************************************************
2423  inline DenseSubvector& operator= ( const ElementType& rhs );
2424  inline DenseSubvector& operator= ( const DenseSubvector& rhs );
2425  template< typename VT2 > inline DenseSubvector& operator= ( const Vector<VT2,TF>& rhs );
2426  template< typename VT2 > inline DenseSubvector& operator+=( const Vector<VT2,TF>& rhs );
2427  template< typename VT2 > inline DenseSubvector& operator-=( const Vector<VT2,TF>& rhs );
2428  template< typename VT2 > inline DenseSubvector& operator*=( const Vector<VT2,TF>& rhs );
2429 
2430  template< typename Other >
2431  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
2432  operator*=( Other rhs );
2433 
2434  template< typename Other >
2435  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
2436  operator/=( Other rhs );
2438  //**********************************************************************************************
2439 
2440  //**Utility functions***************************************************************************
2443  inline size_t size() const;
2444  inline size_t capacity() const;
2445  inline size_t nonZeros() const;
2446  inline void reset();
2447  template< typename Other > inline DenseSubvector& scale( const Other& scalar );
2449  //**********************************************************************************************
2450 
2451  private:
2452  //**********************************************************************************************
2454  template< typename VT2 >
2455  struct VectorizedAssign {
2456  enum { value = vectorizable && VT2::vectorizable &&
2457  IsSame<ElementType,typename VT2::ElementType>::value };
2458  };
2459  //**********************************************************************************************
2460 
2461  //**********************************************************************************************
2463  template< typename VT2 >
2464  struct VectorizedAddAssign {
2465  enum { value = vectorizable && VT2::vectorizable &&
2466  IsSame<ElementType,typename VT2::ElementType>::value &&
2467  IntrinsicTrait<ElementType>::addition };
2468  };
2469  //**********************************************************************************************
2470 
2471  //**********************************************************************************************
2473  template< typename VT2 >
2474  struct VectorizedSubAssign {
2475  enum { value = vectorizable && VT2::vectorizable &&
2476  IsSame<ElementType,typename VT2::ElementType>::value &&
2477  IntrinsicTrait<ElementType>::subtraction };
2478  };
2479  //**********************************************************************************************
2480 
2481  //**********************************************************************************************
2483  template< typename VT2 >
2484  struct VectorizedMultAssign {
2485  enum { value = vectorizable && VT2::vectorizable &&
2486  IsSame<ElementType,typename VT2::ElementType>::value &&
2487  IntrinsicTrait<ElementType>::multiplication };
2488  };
2489  //**********************************************************************************************
2490 
2491  public:
2492  //**Expression template evaluation functions****************************************************
2495  template< typename Other >
2496  inline bool canAlias( const Other* alias ) const;
2497 
2498  template< typename VT2, bool AF2, bool TF2 >
2499  inline bool canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
2500 
2501  template< typename Other >
2502  inline bool isAliased( const Other* alias ) const;
2503 
2504  template< typename VT2, bool AF2, bool TF2 >
2505  inline bool isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const;
2506 
2507  inline bool isAligned () const;
2508  inline bool canSMPAssign() const;
2509 
2510  inline IntrinsicType load ( size_t index ) const;
2511  inline IntrinsicType loadu( size_t index ) const;
2512 
2513  inline void store ( size_t index, const IntrinsicType& value );
2514  inline void storeu( size_t index, const IntrinsicType& value );
2515  inline void stream( size_t index, const IntrinsicType& value );
2516 
2517  template< typename VT2 >
2518  inline typename DisableIf< VectorizedAssign<VT2> >::Type
2519  assign( const DenseVector <VT2,TF>& rhs );
2520 
2521  template< typename VT2 >
2522  inline typename EnableIf< VectorizedAssign<VT2> >::Type
2523  assign( const DenseVector <VT2,TF>& rhs );
2524 
2525  template< typename VT2 > inline void assign( const SparseVector<VT2,TF>& rhs );
2526 
2527  template< typename VT2 >
2528  inline typename DisableIf< VectorizedAddAssign<VT2> >::Type
2529  addAssign( const DenseVector <VT2,TF>& rhs );
2530 
2531  template< typename VT2 >
2532  inline typename EnableIf< VectorizedAddAssign<VT2> >::Type
2533  addAssign ( const DenseVector <VT2,TF>& rhs );
2534 
2535  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
2536 
2537  template< typename VT2 >
2538  inline typename DisableIf< VectorizedSubAssign<VT2> >::Type
2539  subAssign ( const DenseVector <VT2,TF>& rhs );
2540 
2541  template< typename VT2 >
2542  inline typename EnableIf< VectorizedSubAssign<VT2> >::Type
2543  subAssign( const DenseVector <VT2,TF>& rhs );
2544 
2545  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
2546 
2547  template< typename VT2 >
2548  inline typename DisableIf< VectorizedMultAssign<VT2> >::Type
2549  multAssign( const DenseVector <VT2,TF>& rhs );
2550 
2551  template< typename VT2 >
2552  inline typename EnableIf< VectorizedMultAssign<VT2> >::Type
2553  multAssign( const DenseVector <VT2,TF>& rhs );
2554 
2555  template< typename VT2 > inline void multAssign( const SparseVector<VT2,TF>& rhs );
2557  //**********************************************************************************************
2558 
2559  private:
2560  //**Member variables****************************************************************************
2563  Operand vector_;
2564  const size_t offset_;
2565  const size_t size_;
2566 
2567  //**********************************************************************************************
2568 
2569  //**Friend declarations*************************************************************************
2570  template< typename VT2, bool AF2, bool TF2 > friend class DenseSubvector;
2571 
2572  template< bool AF1, typename VT2, bool AF2, bool TF2 >
2573  friend const DenseSubvector<VT2,AF1,TF2>
2574  subvector( const DenseSubvector<VT2,AF2,TF2>& dv, size_t index, size_t size );
2575 
2576  template< typename VT2, bool AF2, bool TF2 >
2577  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseVector<VT2,TF2>& b );
2578 
2579  template< typename VT2, bool AF2, bool TF2 >
2580  friend bool isSame( const DenseVector<VT2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
2581 
2582  template< typename VT2, bool AF2, bool TF2 >
2583  friend bool isSame( const DenseSubvector<VT2,AF2,TF2>& a, const DenseSubvector<VT2,AF2,TF2>& b );
2584 
2585  template< typename VT2, bool AF2, bool TF2 >
2586  friend typename DerestrictTrait< DenseSubvector<VT2,AF2,TF2> >::Type
2587  derestrict( DenseSubvector<VT2,AF2,TF2>& dv );
2588  //**********************************************************************************************
2589 
2590  //**Compile time checks*************************************************************************
2596  //**********************************************************************************************
2597 };
2599 //*************************************************************************************************
2600 
2601 
2602 
2603 
2604 //=================================================================================================
2605 //
2606 // CONSTRUCTOR
2607 //
2608 //=================================================================================================
2609 
2610 //*************************************************************************************************
2623 template< typename VT // Type of the dense vector
2624  , bool TF > // Transpose flag
2625 inline DenseSubvector<VT,aligned,TF>::DenseSubvector( Operand vector, size_t index, size_t n )
2626  : vector_( vector ) // The vector containing the subvector
2627  , offset_( index ) // The offset of the subvector within the dense vector
2628  , size_ ( n ) // The size of the subvector
2629 {
2630  if( index + n > vector.size() )
2631  throw std::invalid_argument( "Invalid subvector specification" );
2632 
2633  if( offset_ % IT::size != 0UL || ( offset_ + size_ != vector_.size() && size_ % IT::size != 0UL ) )
2634  throw std::invalid_argument( "Invalid subvector alignment" );
2635 }
2637 //*************************************************************************************************
2638 
2639 
2640 
2641 
2642 //=================================================================================================
2643 //
2644 // DATA ACCESS FUNCTIONS
2645 //
2646 //=================================================================================================
2647 
2648 //*************************************************************************************************
2655 template< typename VT // Type of the dense vector
2656  , bool TF > // Transpose flag
2659 {
2660  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
2661  return vector_[offset_+index];
2662 }
2664 //*************************************************************************************************
2665 
2666 
2667 //*************************************************************************************************
2674 template< typename VT // Type of the dense vector
2675  , bool TF > // Transpose flag
2677  DenseSubvector<VT,aligned,TF>::operator[]( size_t index ) const
2678 {
2679  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
2680  return const_cast<const VT&>( vector_ )[offset_+index];
2681 }
2683 //*************************************************************************************************
2684 
2685 
2686 //*************************************************************************************************
2694 template< typename VT // Type of the dense vector
2695  , bool TF > // Transpose flag
2696 inline typename DenseSubvector<VT,aligned,TF>::Pointer DenseSubvector<VT,aligned,TF>::data()
2697 {
2698  return vector_.data() + offset_;
2699 }
2701 //*************************************************************************************************
2702 
2703 
2704 //*************************************************************************************************
2712 template< typename VT // Type of the dense vector
2713  , bool TF > // Transpose flag
2714 inline typename DenseSubvector<VT,aligned,TF>::ConstPointer DenseSubvector<VT,aligned,TF>::data() const
2715 {
2716  return vector_.data() + offset_;
2717 }
2719 //*************************************************************************************************
2720 
2721 
2722 //*************************************************************************************************
2730 template< typename VT // Type of the dense vector
2731  , bool TF > // Transpose flag
2733 {
2734  return ( vector_.begin() + offset_ );
2735 }
2737 //*************************************************************************************************
2738 
2739 
2740 //*************************************************************************************************
2748 template< typename VT // Type of the dense vector
2749  , bool TF > // Transpose flag
2752 {
2753  return ( vector_.cbegin() + offset_ );
2754 }
2756 //*************************************************************************************************
2757 
2758 
2759 //*************************************************************************************************
2767 template< typename VT // Type of the dense vector
2768  , bool TF > // Transpose flag
2771 {
2772  return ( vector_.cbegin() + offset_ );
2773 }
2775 //*************************************************************************************************
2776 
2777 
2778 //*************************************************************************************************
2786 template< typename VT // Type of the dense vector
2787  , bool TF > // Transpose flag
2789 {
2790  return ( vector_.begin() + offset_ + size_ );
2791 }
2793 //*************************************************************************************************
2794 
2795 
2796 //*************************************************************************************************
2804 template< typename VT // Type of the dense vector
2805  , bool TF > // Transpose flag
2808 {
2809  return ( vector_.cbegin() + offset_ + size_ );
2810 }
2812 //*************************************************************************************************
2813 
2814 
2815 //*************************************************************************************************
2823 template< typename VT // Type of the dense vector
2824  , bool TF > // Transpose flag
2827 {
2828  return ( vector_.cbegin() + offset_ + size_ );
2829 }
2831 //*************************************************************************************************
2832 
2833 
2834 
2835 
2836 //=================================================================================================
2837 //
2838 // ASSIGNMENT OPERATORS
2839 //
2840 //=================================================================================================
2841 
2842 //*************************************************************************************************
2849 template< typename VT // Type of the dense vector
2850  , bool TF > // Transpose flag
2851 inline DenseSubvector<VT,aligned,TF>&
2853 {
2854  const size_t iend( offset_ + size_ );
2855 
2856  for( size_t i=offset_; i<iend; ++i )
2857  vector_[i] = rhs;
2858 
2859  return *this;
2860 }
2862 //*************************************************************************************************
2863 
2864 
2865 //*************************************************************************************************
2876 template< typename VT // Type of the dense vector
2877  , bool TF > // Transpose flag
2878 inline DenseSubvector<VT,aligned,TF>&
2879  DenseSubvector<VT,aligned,TF>::operator=( const DenseSubvector& rhs )
2880 {
2883 
2884  if( &rhs == this || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
2885  return *this;
2886 
2887  if( size() != rhs.size() )
2888  throw std::invalid_argument( "Subvector sizes do not match" );
2889 
2890  if( rhs.canAlias( &vector_ ) ) {
2891  const ResultType tmp( ~rhs );
2892  smpAssign( *this, tmp );
2893  }
2894  else {
2895  smpAssign( *this, rhs );
2896  }
2897 
2898  return *this;
2899 }
2901 //*************************************************************************************************
2902 
2903 
2904 //*************************************************************************************************
2915 template< typename VT // Type of the dense vector
2916  , bool TF > // Transpose flag
2917 template< typename VT2 > // Type of the right-hand side vector
2918 inline DenseSubvector<VT,aligned,TF>&
2919  DenseSubvector<VT,aligned,TF>::operator=( const Vector<VT2,TF>& rhs )
2920 {
2923 
2924  if( size() != (~rhs).size() )
2925  throw std::invalid_argument( "Vector sizes do not match" );
2926 
2927  if( (~rhs).canAlias( &vector_ ) ) {
2928  const typename VT2::ResultType tmp( ~rhs );
2929  smpAssign( *this, tmp );
2930  }
2931  else {
2932  if( IsSparseVector<VT2>::value )
2933  reset();
2934  smpAssign( *this, ~rhs );
2935  }
2936 
2937  return *this;
2938 }
2940 //*************************************************************************************************
2941 
2942 
2943 //*************************************************************************************************
2954 template< typename VT // Type of the dense vector
2955  , bool TF > // Transpose flag
2956 template< typename VT2 > // Type of the right-hand side vector
2957 inline DenseSubvector<VT,aligned,TF>&
2958  DenseSubvector<VT,aligned,TF>::operator+=( const Vector<VT2,TF>& rhs )
2959 {
2962 
2963  if( size() != (~rhs).size() )
2964  throw std::invalid_argument( "Vector sizes do not match" );
2965 
2966  if( (~rhs).canAlias( &vector_ ) ) {
2967  const typename VT2::ResultType tmp( ~rhs );
2968  smpAddAssign( *this, tmp );
2969  }
2970  else {
2971  smpAddAssign( *this, ~rhs );
2972  }
2973 
2974  return *this;
2975 }
2977 //*************************************************************************************************
2978 
2979 
2980 //*************************************************************************************************
2991 template< typename VT // Type of the dense vector
2992  , bool TF > // Transpose flag
2993 template< typename VT2 > // Type of the right-hand side vector
2994 inline DenseSubvector<VT,aligned,TF>&
2995  DenseSubvector<VT,aligned,TF>::operator-=( const Vector<VT2,TF>& rhs )
2996 {
2999 
3000  if( size() != (~rhs).size() )
3001  throw std::invalid_argument( "Vector sizes do not match" );
3002 
3003  if( (~rhs).canAlias( &vector_ ) ) {
3004  const typename VT2::ResultType tmp( ~rhs );
3005  smpSubAssign( *this, tmp );
3006  }
3007  else {
3008  smpSubAssign( *this, ~rhs );
3009  }
3010 
3011  return *this;
3012 }
3014 //*************************************************************************************************
3015 
3016 
3017 //*************************************************************************************************
3029 template< typename VT // Type of the dense vector
3030  , bool TF > // Transpose flag
3031 template< typename VT2 > // Type of the right-hand side vector
3032 inline DenseSubvector<VT,aligned,TF>&
3033  DenseSubvector<VT,aligned,TF>::operator*=( const Vector<VT2,TF>& rhs )
3034 {
3037 
3038  if( size() != (~rhs).size() )
3039  throw std::invalid_argument( "Vector sizes do not match" );
3040 
3041  if( (~rhs).canAlias( &vector_ ) || IsSparseVector<VT2>::value ) {
3042  const ResultType tmp( *this * (~rhs) );
3043  smpAssign( *this, tmp );
3044  }
3045  else {
3046  smpMultAssign( *this, ~rhs );
3047  }
3048 
3049  return *this;
3050 }
3052 //*************************************************************************************************
3053 
3054 
3055 //*************************************************************************************************
3063 template< typename VT // Type of the dense vector
3064  , bool TF > // Transpose flag
3065 template< typename Other > // Data type of the right-hand side scalar
3066 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,aligned,TF> >::Type&
3067  DenseSubvector<VT,aligned,TF>::operator*=( Other rhs )
3068 {
3069  smpAssign( *this, (*this) * rhs );
3070  return *this;
3071 }
3073 //*************************************************************************************************
3074 
3075 
3076 //*************************************************************************************************
3086 template< typename VT // Type of the dense vector
3087  , bool TF > // Transpose flag
3088 template< typename Other > // Data type of the right-hand side scalar
3089 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,aligned,TF> >::Type&
3090  DenseSubvector<VT,aligned,TF>::operator/=( Other rhs )
3091 {
3092  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3093 
3094  smpAssign( *this, (*this) / rhs );
3095  return *this;
3096 }
3098 //*************************************************************************************************
3099 
3100 
3101 
3102 
3103 //=================================================================================================
3104 //
3105 // UTILITY FUNCTIONS
3106 //
3107 //=================================================================================================
3108 
3109 //*************************************************************************************************
3115 template< typename VT // Type of the dense vector
3116  , bool TF > // Transpose flag
3117 inline size_t DenseSubvector<VT,aligned,TF>::size() const
3118 {
3119  return size_;
3120 }
3122 //*************************************************************************************************
3123 
3124 
3125 //*************************************************************************************************
3131 template< typename VT // Type of the dense vector
3132  , bool TF > // Transpose flag
3133 inline size_t DenseSubvector<VT,aligned,TF>::capacity() const
3134 {
3135  return vector_.capacity() - offset_;
3136 }
3138 //*************************************************************************************************
3139 
3140 
3141 //*************************************************************************************************
3150 template< typename VT // Type of the dense vector
3151  , bool TF > // Transpose flag
3152 inline size_t DenseSubvector<VT,aligned,TF>::nonZeros() const
3153 {
3154  size_t nonzeros( 0 );
3155 
3156  const size_t iend( offset_ + size_ );
3157  for( size_t i=offset_; i<iend; ++i ) {
3158  if( !isDefault( vector_[i] ) )
3159  ++nonzeros;
3160  }
3161 
3162  return nonzeros;
3163 }
3165 //*************************************************************************************************
3166 
3167 
3168 //*************************************************************************************************
3174 template< typename VT // Type of the dense vector
3175  , bool TF > // Transpose flag
3177 {
3178  using blaze::clear;
3179 
3180  const size_t iend( offset_ + size_ );
3181  for( size_t i=offset_; i<iend; ++i )
3182  clear( vector_[i] );
3183 }
3185 //*************************************************************************************************
3186 
3187 
3188 //*************************************************************************************************
3195 template< typename VT // Type of the dense vector
3196  , bool TF > // Transpose flag
3197 template< typename Other > // Data type of the scalar value
3198 inline DenseSubvector<VT,aligned,TF>& DenseSubvector<VT,aligned,TF>::scale( const Other& scalar )
3199 {
3200  const size_t iend( offset_ + size_ );
3201  for( size_t i=offset_; i<iend; ++i )
3202  vector_[i] *= scalar;
3203  return *this;
3204 }
3206 //*************************************************************************************************
3207 
3208 
3209 
3210 
3211 //=================================================================================================
3212 //
3213 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3214 //
3215 //=================================================================================================
3216 
3217 //*************************************************************************************************
3228 template< typename VT // Type of the dense vector
3229  , bool TF > // Transpose flag
3230 template< typename Other > // Data type of the foreign expression
3231 inline bool DenseSubvector<VT,aligned,TF>::canAlias( const Other* alias ) const
3232 {
3233  return vector_.isAliased( alias );
3234 }
3236 //*************************************************************************************************
3237 
3238 
3239 //*************************************************************************************************
3250 template< typename VT // Type of the dense vector
3251  , bool TF > // Transpose flag
3252 template< typename VT2 // Data type of the foreign dense subvector
3253  , bool AF2 // Alignment flag of the foreign dense subvector
3254  , bool TF2 > // Transpose flag of the foreign dense subvector
3255 inline bool DenseSubvector<VT,aligned,TF>::canAlias( const DenseSubvector<VT2,AF2,TF2>* alias ) const
3256 {
3257  return ( vector_.isAliased( &alias->vector_ ) &&
3258  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
3259 }
3261 //*************************************************************************************************
3262 
3263 
3264 //*************************************************************************************************
3275 template< typename VT // Type of the dense vector
3276  , bool TF > // Transpose flag
3277 template< typename Other > // Data type of the foreign expression
3278 inline bool DenseSubvector<VT,aligned,TF>::isAliased( const Other* alias ) const
3279 {
3280  return vector_.isAliased( alias );
3281 }
3283 //*************************************************************************************************
3284 
3285 
3286 //*************************************************************************************************
3297 template< typename VT // Type of the dense vector
3298  , bool TF > // Transpose flag
3299 template< typename VT2 // Data type of the foreign dense subvector
3300  , bool AF2 // Alignment flag of the foreign dense subvector
3301  , bool TF2 > // Transpose flag of the foreign dense subvector
3302 inline bool DenseSubvector<VT,aligned,TF>::isAliased( const DenseSubvector<VT2,AF2,TF2>* alias ) const
3303 {
3304  return ( vector_.isAliased( &alias->vector_ ) &&
3305  ( offset_ + size_ > alias->offset_ ) && ( offset_ < alias->offset_ + alias->size_ ) );
3306 }
3308 //*************************************************************************************************
3309 
3310 
3311 //*************************************************************************************************
3321 template< typename VT // Type of the dense vector
3322  , bool TF > // Transpose flag
3323 inline bool DenseSubvector<VT,aligned,TF>::isAligned() const
3324 {
3325  return true;
3326 }
3328 //*************************************************************************************************
3329 
3330 
3331 //*************************************************************************************************
3342 template< typename VT // Type of the dense vector
3343  , bool TF > // Transpose flag
3345 {
3346  return ( size() > SMP_DVECASSIGN_THRESHOLD );
3347 }
3349 //*************************************************************************************************
3350 
3351 
3352 //*************************************************************************************************
3366 template< typename VT // Type of the dense vector
3367  , bool TF > // Transpose flag
3368 BLAZE_ALWAYS_INLINE typename DenseSubvector<VT,aligned,TF>::IntrinsicType
3369  DenseSubvector<VT,aligned,TF>::load( size_t index ) const
3370 {
3372 
3373  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3374  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3375 
3376  return vector_.load( offset_+index );
3377 }
3379 //*************************************************************************************************
3380 
3381 
3382 //*************************************************************************************************
3396 template< typename VT // Type of the dense vector
3397  , bool TF > // Transpose flag
3398 BLAZE_ALWAYS_INLINE typename DenseSubvector<VT,aligned,TF>::IntrinsicType
3399  DenseSubvector<VT,aligned,TF>::loadu( size_t index ) const
3400 {
3402 
3403  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3404  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3405 
3406  return vector_.loadu( offset_+index );
3407 }
3409 //*************************************************************************************************
3410 
3411 
3412 //*************************************************************************************************
3427 template< typename VT // Type of the dense vector
3428  , bool TF > // Transpose flag
3430  DenseSubvector<VT,aligned,TF>::store( size_t index, const IntrinsicType& value )
3431 {
3433 
3434  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3435  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3436 
3437  vector_.store( offset_+index, value );
3438 }
3440 //*************************************************************************************************
3441 
3442 
3443 //*************************************************************************************************
3458 template< typename VT // Type of the dense vector
3459  , bool TF > // Transpose flag
3461  DenseSubvector<VT,aligned,TF>::storeu( size_t index, const IntrinsicType& value )
3462 {
3464 
3465  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3466  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3467 
3468  vector_.storeu( offset_+index, value );
3469 }
3471 //*************************************************************************************************
3472 
3473 
3474 //*************************************************************************************************
3489 template< typename VT // Type of the dense vector
3490  , bool TF > // Transpose flag
3492  DenseSubvector<VT,aligned,TF>::stream( size_t index, const IntrinsicType& value )
3493 {
3495 
3496  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
3497  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
3498 
3499  vector_.stream( offset_+index, value );
3500 }
3502 //*************************************************************************************************
3503 
3504 
3505 //*************************************************************************************************
3517 template< typename VT // Type of the dense vector
3518  , bool TF > // Transpose flag
3519 template< typename VT2 > // Type of the right-hand side dense vector
3520 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
3521  DenseSubvector<VT,aligned,TF>::assign( const DenseVector<VT2,TF>& rhs )
3522 {
3523  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3524 
3525  const size_t ipos( size() & size_t(-2) );
3526  for( size_t i=0UL; i<ipos; i+=2UL ) {
3527  vector_[i+offset_ ] = (~rhs)[i ];
3528  vector_[i+offset_+1UL] = (~rhs)[i+1UL];
3529  }
3530  if( ipos < size() ) {
3531  vector_[ipos+offset_] = (~rhs)[ipos];
3532  }
3533 }
3535 //*************************************************************************************************
3536 
3537 
3538 //*************************************************************************************************
3550 template< typename VT // Type of the dense vector
3551  , bool TF > // Transpose flag
3552 template< typename VT2 > // Type of the right-hand side dense vector
3553 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
3554  DenseSubvector<VT,aligned,TF>::assign( const DenseVector<VT2,TF>& rhs )
3555 {
3556  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3557 
3559 
3560  if( useStreaming && size_ > ( cacheSize/( sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &vector_ ) )
3561  {
3562  for( size_t i=0UL; i<size(); i+=IT::size ) {
3563  vector_.stream( offset_+i, (~rhs).load(i) );
3564  }
3565  }
3566  else
3567  {
3568  const size_t ipos( size_ & size_t(-IT::size*4) );
3569  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
3570 
3571  typename VT2::ConstIterator it( (~rhs).begin() );
3572  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
3573  store( i , it.load() ); it += IT::size;
3574  store( i+IT::size , it.load() ); it += IT::size;
3575  store( i+IT::size*2UL, it.load() ); it += IT::size;
3576  store( i+IT::size*3UL, it.load() ); it += IT::size;
3577  }
3578  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
3579  store( i, it.load() );
3580  }
3581  }
3582 }
3584 //*************************************************************************************************
3585 
3586 
3587 //*************************************************************************************************
3599 template< typename VT // Type of the dense vector
3600  , bool TF > // Transpose flag
3601 template< typename VT2 > // Type of the right-hand side dense vector
3602 inline void DenseSubvector<VT,aligned,TF>::assign( const SparseVector<VT2,TF>& rhs )
3603 {
3604  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3605 
3606  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3607  vector_[element->index()+offset_] = element->value();
3608 }
3610 //*************************************************************************************************
3611 
3612 
3613 //*************************************************************************************************
3625 template< typename VT // Type of the dense vector
3626  , bool TF > // Transpose flag
3627 template< typename VT2 > // Type of the right-hand side dense vector
3628 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
3629  DenseSubvector<VT,aligned,TF>::addAssign( const DenseVector<VT2,TF>& rhs )
3630 {
3631  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3632 
3633  const size_t ipos( size() & size_t(-2) );
3634  for( size_t i=0UL; i<ipos; i+=2UL ) {
3635  vector_[i+offset_ ] += (~rhs)[i ];
3636  vector_[i+offset_+1UL] += (~rhs)[i+1UL];
3637  }
3638  if( ipos < size() ) {
3639  vector_[ipos+offset_] += (~rhs)[ipos];
3640  }
3641 }
3643 //*************************************************************************************************
3644 
3645 
3646 //*************************************************************************************************
3658 template< typename VT // Type of the dense vector
3659  , bool TF > // Transpose flag
3660 template< typename VT2 > // Type of the right-hand side dense vector
3661 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
3662  DenseSubvector<VT,aligned,TF>::addAssign( const DenseVector<VT2,TF>& rhs )
3663 {
3664  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3665 
3667 
3668  const size_t ipos( size_ & size_t(-IT::size*4) );
3669  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
3670 
3671  typename VT2::ConstIterator it( (~rhs).begin() );
3672  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
3673  store( i , load(i ) + it.load() ); it += IT::size;
3674  store( i+IT::size , load(i+IT::size ) + it.load() ); it += IT::size;
3675  store( i+IT::size*2UL, load(i+IT::size*2UL) + it.load() ); it += IT::size;
3676  store( i+IT::size*3UL, load(i+IT::size*3UL) + it.load() ); it += IT::size;
3677  }
3678  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
3679  store( i, load(i) + it.load() );
3680  }
3681 }
3683 //*************************************************************************************************
3684 
3685 
3686 //*************************************************************************************************
3698 template< typename VT // Type of the dense vector
3699  , bool TF > // Transpose flag
3700 template< typename VT2 > // Type of the right-hand side dense vector
3701 inline void DenseSubvector<VT,aligned,TF>::addAssign( const SparseVector<VT2,TF>& rhs )
3702 {
3703  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3704 
3705  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3706  vector_[element->index()+offset_] += element->value();
3707 }
3709 //*************************************************************************************************
3710 
3711 
3712 //*************************************************************************************************
3724 template< typename VT // Type of the dense vector
3725  , bool TF > // Transpose flag
3726 template< typename VT2 > // Type of the right-hand side dense vector
3727 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
3728  DenseSubvector<VT,aligned,TF>::subAssign( const DenseVector<VT2,TF>& rhs )
3729 {
3730  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3731 
3732  const size_t ipos( size() & size_t(-2) );
3733  for( size_t i=0UL; i<ipos; i+=2UL ) {
3734  vector_[i+offset_ ] -= (~rhs)[i ];
3735  vector_[i+offset_+1UL] -= (~rhs)[i+1UL];
3736  }
3737  if( ipos < size() ) {
3738  vector_[ipos+offset_] -= (~rhs)[ipos];
3739  }
3740 }
3742 //*************************************************************************************************
3743 
3744 
3745 //*************************************************************************************************
3757 template< typename VT // Type of the dense vector
3758  , bool TF > // Transpose flag
3759 template< typename VT2 > // Type of the right-hand side dense vector
3760 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
3761  DenseSubvector<VT,aligned,TF>::subAssign( const DenseVector<VT2,TF>& rhs )
3762 {
3763  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3764 
3766 
3767  const size_t ipos( size_ & size_t(-IT::size*4) );
3768  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
3769 
3770  typename VT2::ConstIterator it( (~rhs).begin() );
3771  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
3772  store( i , load(i ) - it.load() ); it += IT::size;
3773  store( i+IT::size , load(i+IT::size ) - it.load() ); it += IT::size;
3774  store( i+IT::size*2UL, load(i+IT::size*2UL) - it.load() ); it += IT::size;
3775  store( i+IT::size*3UL, load(i+IT::size*3UL) - it.load() ); it += IT::size;
3776  }
3777  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
3778  store( i, load(i) - it.load() );
3779  }
3780 }
3782 //*************************************************************************************************
3783 
3784 
3785 //*************************************************************************************************
3797 template< typename VT // Type of the dense vector
3798  , bool TF > // Transpose flag
3799 template< typename VT2 > // Type of the right-hand side dense vector
3800 inline void DenseSubvector<VT,aligned,TF>::subAssign( const SparseVector<VT2,TF>& rhs )
3801 {
3802  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3803 
3804  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3805  vector_[element->index()+offset_] -= element->value();
3806 }
3808 //*************************************************************************************************
3809 
3810 
3811 //*************************************************************************************************
3823 template< typename VT // Type of the dense vector
3824  , bool TF > // Transpose flag
3825 template< typename VT2 > // Type of the right-hand side dense vector
3826 inline typename DisableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
3827  DenseSubvector<VT,aligned,TF>::multAssign( const DenseVector<VT2,TF>& rhs )
3828 {
3829  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3830 
3831  const size_t ipos( size() & size_t(-2) );
3832  for( size_t i=0UL; i<ipos; i+=2UL ) {
3833  vector_[i+offset_ ] *= (~rhs)[i ];
3834  vector_[i+offset_+1UL] *= (~rhs)[i+1UL];
3835  }
3836  if( ipos < size() ) {
3837  vector_[ipos+offset_] *= (~rhs)[ipos];
3838  }
3839 }
3841 //*************************************************************************************************
3842 
3843 
3844 //*************************************************************************************************
3856 template< typename VT // Type of the dense vector
3857  , bool TF > // Transpose flag
3858 template< typename VT2 > // Type of the right-hand side dense vector
3859 inline typename EnableIf< typename DenseSubvector<VT,aligned,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
3860  DenseSubvector<VT,aligned,TF>::multAssign( const DenseVector<VT2,TF>& rhs )
3861 {
3862  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3863 
3865 
3866  const size_t ipos( size_ & size_t(-IT::size*4) );
3867  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
3868 
3869  typename VT2::ConstIterator it( (~rhs).begin() );
3870  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
3871  store( i , load(i ) * it.load() ); it += IT::size;
3872  store( i+IT::size , load(i+IT::size ) * it.load() ); it += IT::size;
3873  store( i+IT::size*2UL, load(i+IT::size*2UL) * it.load() ); it += IT::size;
3874  store( i+IT::size*3UL, load(i+IT::size*3UL) * it.load() ); it += IT::size;
3875  }
3876  for( size_t i=ipos; i<size_; i+=IT::size, it+=IT::size ) {
3877  store( i, load(i) * it.load() );
3878  }
3879 }
3881 //*************************************************************************************************
3882 
3883 
3884 //*************************************************************************************************
3896 template< typename VT // Type of the dense vector
3897  , bool TF > // Transpose flag
3898 template< typename VT2 > // Type of the right-hand side dense vector
3899 inline void DenseSubvector<VT,aligned,TF>::multAssign( const SparseVector<VT2,TF>& rhs )
3900 {
3901  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3902 
3903  const ResultType tmp( serial( *this ) );
3904 
3905  reset();
3906 
3907  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3908  vector_[element->index()+offset_] = tmp[element->index()] * element->value();
3909 }
3911 //*************************************************************************************************
3912 
3913 
3914 
3915 
3916 
3917 
3918 
3919 
3920 //=================================================================================================
3921 //
3922 // CLASS TEMPLATE SPECIALIZATION FOR DVECDVECCROSSEXPR
3923 //
3924 //=================================================================================================
3925 
3926 //*************************************************************************************************
3934 template< typename VT1 // Type of the left-hand side dense vector
3935  , typename VT2 > // Type of the right-hand side dense vector
3936 class DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false >
3937  : public DenseVector< DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false >, false >
3938  , private Subvector
3939 {
3940  private:
3941  //**Type definitions****************************************************************************
3942  typedef DVecDVecCrossExpr<VT1,VT2> CPE;
3943  typedef typename CPE::ResultType RT;
3944  //**********************************************************************************************
3945 
3946  public:
3947  //**Type definitions****************************************************************************
3948  typedef DenseSubvector<CPE,unaligned,false> This;
3949  typedef typename SubvectorTrait<RT>::Type ResultType;
3950  typedef typename ResultType::TransposeType TransposeType;
3951  typedef typename CPE::ElementType ElementType;
3952  typedef typename CPE::ReturnType ReturnType;
3953  typedef const ResultType CompositeType;
3954  //**********************************************************************************************
3955 
3956  //**Compilation flags***************************************************************************
3958  enum { vectorizable = 0 };
3959 
3961  enum { smpAssignable = 0 };
3962  //**********************************************************************************************
3963 
3964  //**Constructor*********************************************************************************
3971  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
3972  : vector_( vector ) // The dense vector/dense vector cross product expression
3973  , offset_( index ) // The offset of the subvector within the cross product expression
3974  , size_ ( n ) // The size of the subvector
3975  {}
3976  //**********************************************************************************************
3977 
3978  //**Subscript operator**************************************************************************
3984  inline ReturnType operator[]( size_t index ) const {
3985  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
3986  return vector_[offset_+index];
3987  }
3988  //**********************************************************************************************
3989 
3990  //**Size function*******************************************************************************
3995  inline size_t size() const {
3996  return size_;
3997  }
3998  //**********************************************************************************************
3999 
4000  //**********************************************************************************************
4006  template< typename T >
4007  inline bool canAlias( const T* alias ) const {
4008  return vector_.canAlias( alias );
4009  }
4010  //**********************************************************************************************
4011 
4012  //**********************************************************************************************
4018  template< typename T >
4019  inline bool isAliased( const T* alias ) const {
4020  return vector_.isAliased( alias );
4021  }
4022  //**********************************************************************************************
4023 
4024  private:
4025  //**Member variables****************************************************************************
4028  CPE vector_;
4029  const size_t offset_;
4030  const size_t size_;
4031 
4032  //**********************************************************************************************
4033 
4034  //**Friend declarations*************************************************************************
4035  template< bool AF1, typename VT, bool AF2, bool TF >
4036  friend const DenseSubvector<VT,AF1,TF>
4037  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4038 
4039  template< typename VT3, bool AF3, bool TF3 >
4040  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4041 
4042  template< typename VT3, bool AF3, bool TF3 >
4043  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4044 
4045  template< typename VT3, bool AF3, bool TF3 >
4046  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4047  //**********************************************************************************************
4048 };
4050 //*************************************************************************************************
4051 
4052 
4053 
4054 
4055 
4056 
4057 
4058 
4059 //=================================================================================================
4060 //
4061 // CLASS TEMPLATE SPECIALIZATION FOR DVECSVECCROSSEXPR
4062 //
4063 //=================================================================================================
4064 
4065 //*************************************************************************************************
4073 template< typename VT1 // Type of the left-hand side dense vector
4074  , typename VT2 > // Type of the right-hand side sparse vector
4075 class DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false >
4076  : public DenseVector< DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4077  , private Subvector
4078 {
4079  private:
4080  //**Type definitions****************************************************************************
4081  typedef DVecSVecCrossExpr<VT1,VT2> CPE;
4082  typedef typename CPE::ResultType RT;
4083  //**********************************************************************************************
4084 
4085  public:
4086  //**Type definitions****************************************************************************
4087  typedef DenseSubvector<CPE,unaligned,false> This;
4088  typedef typename SubvectorTrait<RT>::Type ResultType;
4089  typedef typename ResultType::TransposeType TransposeType;
4090  typedef typename CPE::ElementType ElementType;
4091  typedef typename CPE::ReturnType ReturnType;
4092  typedef const ResultType CompositeType;
4093  //**********************************************************************************************
4094 
4095  //**Compilation flags***************************************************************************
4097  enum { vectorizable = 0 };
4098 
4100  enum { smpAssignable = 0 };
4101  //**********************************************************************************************
4102 
4103  //**Constructor*********************************************************************************
4110  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4111  : vector_( vector ) // The dense vector/sparse vector cross product expression
4112  , offset_( index ) // The offset of the subvector within the cross product expression
4113  , size_ ( n ) // The size of the subvector
4114  {}
4115  //**********************************************************************************************
4116 
4117  //**Subscript operator**************************************************************************
4123  inline ReturnType operator[]( size_t index ) const {
4124  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4125  return vector_[offset_+index];
4126  }
4127  //**********************************************************************************************
4128 
4129  //**Size function*******************************************************************************
4134  inline size_t size() const {
4135  return size_;
4136  }
4137  //**********************************************************************************************
4138 
4139  //**********************************************************************************************
4145  template< typename T >
4146  inline bool canAlias( const T* alias ) const {
4147  return vector_.canAlias( alias );
4148  }
4149  //**********************************************************************************************
4150 
4151  //**********************************************************************************************
4157  template< typename T >
4158  inline bool isAliased( const T* alias ) const {
4159  return vector_.isAliased( alias );
4160  }
4161  //**********************************************************************************************
4162 
4163  private:
4164  //**Member variables****************************************************************************
4167  CPE vector_;
4168  const size_t offset_;
4169  const size_t size_;
4170 
4171  //**********************************************************************************************
4172 
4173  //**Friend declarations*************************************************************************
4174  template< bool AF1, typename VT, bool AF2, bool TF >
4175  friend const DenseSubvector<VT,AF1,TF>
4176  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4177 
4178  template< typename VT3, bool AF3, bool TF3 >
4179  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4180 
4181  template< typename VT3, bool AF3, bool TF3 >
4182  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4183 
4184  template< typename VT3, bool AF3, bool TF3 >
4185  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4186  //**********************************************************************************************
4187 };
4189 //*************************************************************************************************
4190 
4191 
4192 
4193 
4194 
4195 
4196 
4197 
4198 //=================================================================================================
4199 //
4200 // CLASS TEMPLATE SPECIALIZATION FOR SVECDVECCROSSEXPR
4201 //
4202 //=================================================================================================
4203 
4204 //*************************************************************************************************
4212 template< typename VT1 // Type of the left-hand side sparse vector
4213  , typename VT2 > // Type of the right-hand side dense vector
4214 class DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false >
4215  : public DenseVector< DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4216  , private Subvector
4217 {
4218  private:
4219  //**Type definitions****************************************************************************
4220  typedef SVecDVecCrossExpr<VT1,VT2> CPE;
4221  typedef typename CPE::ResultType RT;
4222  //**********************************************************************************************
4223 
4224  public:
4225  //**Type definitions****************************************************************************
4226  typedef DenseSubvector<CPE,unaligned,false> This;
4227  typedef typename SubvectorTrait<RT>::Type ResultType;
4228  typedef typename ResultType::TransposeType TransposeType;
4229  typedef typename CPE::ElementType ElementType;
4230  typedef typename CPE::ReturnType ReturnType;
4231  typedef const ResultType CompositeType;
4232  //**********************************************************************************************
4233 
4234  //**Compilation flags***************************************************************************
4236  enum { vectorizable = 0 };
4237 
4239  enum { smpAssignable = 0 };
4240  //**********************************************************************************************
4241 
4242  //**Constructor*********************************************************************************
4249  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4250  : vector_( vector ) // The sparse vector/dense vector cross product expression
4251  , offset_( index ) // The offset of the subvector within the cross product expression
4252  , size_ ( n ) // The size of the subvector
4253  {}
4254  //**********************************************************************************************
4255 
4256  //**Subscript operator**************************************************************************
4262  inline ReturnType operator[]( size_t index ) const {
4263  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4264  return vector_[offset_+index];
4265  }
4266  //**********************************************************************************************
4267 
4268  //**Size function*******************************************************************************
4273  inline size_t size() const {
4274  return size_;
4275  }
4276  //**********************************************************************************************
4277 
4278  //**********************************************************************************************
4284  template< typename T >
4285  inline bool canAlias( const T* alias ) const {
4286  return vector_.canAlias( alias );
4287  }
4288  //**********************************************************************************************
4289 
4290  //**********************************************************************************************
4296  template< typename T >
4297  inline bool isAliased( const T* alias ) const {
4298  return vector_.isAliased( alias );
4299  }
4300  //**********************************************************************************************
4301 
4302  private:
4303  //**Member variables****************************************************************************
4306  CPE vector_;
4307  const size_t offset_;
4308  const size_t size_;
4309 
4310  //**********************************************************************************************
4311 
4312  //**Friend declarations*************************************************************************
4313  template< bool AF1, typename VT, bool AF2, bool TF >
4314  friend const DenseSubvector<VT,AF1,TF>
4315  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4316 
4317  template< typename VT3, bool AF3, bool TF3 >
4318  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4319 
4320  template< typename VT3, bool AF3, bool TF3 >
4321  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4322 
4323  template< typename VT3, bool AF3, bool TF3 >
4324  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4325  //**********************************************************************************************
4326 };
4328 //*************************************************************************************************
4329 
4330 
4331 
4332 
4333 
4334 
4335 
4336 
4337 //=================================================================================================
4338 //
4339 // CLASS TEMPLATE SPECIALIZATION FOR SVECSVECCROSSEXPR
4340 //
4341 //=================================================================================================
4342 
4343 //*************************************************************************************************
4351 template< typename VT1 // Type of the left-hand side sparse vector
4352  , typename VT2 > // Type of the right-hand side sparse vector
4353 class DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false >
4354  : public DenseVector< DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false >, false >
4355  , private Subvector
4356 {
4357  private:
4358  //**Type definitions****************************************************************************
4359  typedef SVecSVecCrossExpr<VT1,VT2> CPE;
4360  typedef typename CPE::ResultType RT;
4361  //**********************************************************************************************
4362 
4363  public:
4364  //**Type definitions****************************************************************************
4365  typedef DenseSubvector<CPE,unaligned,false> This;
4366  typedef typename SubvectorTrait<RT>::Type ResultType;
4367  typedef typename ResultType::TransposeType TransposeType;
4368  typedef typename CPE::ElementType ElementType;
4369  typedef typename CPE::ReturnType ReturnType;
4370  typedef const ResultType CompositeType;
4371  //**********************************************************************************************
4372 
4373  //**Compilation flags***************************************************************************
4375  enum { vectorizable = 0 };
4376 
4378  enum { smpAssignable = 0 };
4379  //**********************************************************************************************
4380 
4381  //**Constructor*********************************************************************************
4388  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
4389  : vector_( vector ) // The sparse vector/sparse vector cross product expression
4390  , offset_( index ) // The offset of the subvector within the cross product expression
4391  , size_ ( n ) // The size of the subvector
4392  {}
4393  //**********************************************************************************************
4394 
4395  //**Subscript operator**************************************************************************
4401  inline ReturnType operator[]( size_t index ) const {
4402  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
4403  return vector_[offset_+index];
4404  }
4405  //**********************************************************************************************
4406 
4407  //**Size function*******************************************************************************
4412  inline size_t size() const {
4413  return size_;
4414  }
4415  //**********************************************************************************************
4416 
4417  //**********************************************************************************************
4423  template< typename T >
4424  inline bool canAlias( const T* alias ) const {
4425  return vector_.canAlias( alias );
4426  }
4427  //**********************************************************************************************
4428 
4429  //**********************************************************************************************
4435  template< typename T >
4436  inline bool isAliased( const T* alias ) const {
4437  return vector_.isAliased( alias );
4438  }
4439  //**********************************************************************************************
4440 
4441  private:
4442  //**Member variables****************************************************************************
4445  CPE vector_;
4446  const size_t offset_;
4447  const size_t size_;
4448 
4449  //**********************************************************************************************
4450 
4451  //**Friend declarations*************************************************************************
4452  template< bool AF1, typename VT, bool AF2, bool TF >
4453  friend const DenseSubvector<VT,AF1,TF>
4454  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size );
4455 
4456  template< typename VT3, bool AF3, bool TF3 >
4457  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseVector<VT3,TF3>& b );
4458 
4459  template< typename VT3, bool AF3, bool TF3 >
4460  friend bool isSame( const DenseVector<VT3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4461 
4462  template< typename VT3, bool AF3, bool TF3 >
4463  friend bool isSame( const DenseSubvector<VT3,AF3,TF3>& a, const DenseSubvector<VT3,AF3,TF3>& b );
4464  //**********************************************************************************************
4465 };
4467 //*************************************************************************************************
4468 
4469 
4470 
4471 
4472 
4473 
4474 
4475 
4476 //=================================================================================================
4477 //
4478 // DENSESUBVECTOR OPERATORS
4479 //
4480 //=================================================================================================
4481 
4482 //*************************************************************************************************
4485 template< typename VT, bool AF, bool TF >
4486 inline void reset( DenseSubvector<VT,AF,TF>& dv );
4487 
4488 template< typename VT, bool AF, bool TF >
4489 inline void clear( DenseSubvector<VT,AF,TF>& dv );
4490 
4491 template< typename VT, bool AF, bool TF >
4492 inline bool isDefault( const DenseSubvector<VT,AF,TF>& dv );
4493 
4494 template< typename VT, bool AF, bool TF >
4495 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseVector<VT,TF>& b );
4496 
4497 template< typename VT, bool AF, bool TF >
4498 inline bool isSame( const DenseVector<VT,TF>& a, const DenseSubvector<VT,AF,TF>& b );
4499 
4500 template< typename VT, bool AF, bool TF >
4501 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseSubvector<VT,AF,TF>& b );
4503 //*************************************************************************************************
4504 
4505 
4506 //*************************************************************************************************
4513 template< typename VT // Type of the dense vector
4514  , bool AF // Alignment flag
4515  , bool TF > // Transpose flag
4517 {
4518  dv.reset();
4519 }
4520 //*************************************************************************************************
4521 
4522 
4523 //*************************************************************************************************
4530 template< typename VT // Type of the dense vector
4531  , bool AF // Alignment flag
4532  , bool TF > // Transpose flag
4534 {
4535  dv.reset();
4536 }
4537 //*************************************************************************************************
4538 
4539 
4540 //*************************************************************************************************
4559 template< typename VT // Type of the dense vector
4560  , bool AF // Alignment flag
4561  , bool TF > // Transpose flag
4562 inline bool isDefault( const DenseSubvector<VT,AF,TF>& dv )
4563 {
4564  for( size_t i=0UL; i<dv.size(); ++i )
4565  if( !isDefault( dv[i] ) ) return false;
4566  return true;
4567 }
4568 //*************************************************************************************************
4569 
4570 
4571 //*************************************************************************************************
4583 template< typename VT // Type of the dense vector
4584  , bool AF // Alignment flag
4585  , bool TF > // Transpose flag
4586 inline bool isSame( const DenseSubvector<VT,AF,TF>& a, const DenseVector<VT,TF>& b )
4587 {
4588  return ( isSame( a.vector_, ~b ) && ( a.size() == (~b).size() ) );
4589 }
4590 //*************************************************************************************************
4591 
4592 
4593 //*************************************************************************************************
4605 template< typename VT // Type of the dense vector
4606  , bool AF // Alignment flag
4607  , bool TF > // Transpose flag
4608 inline bool isSame( const DenseVector<VT,TF>& a, const DenseSubvector<VT,AF,TF>& b )
4609 {
4610  return ( isSame( ~a, b.vector_ ) && ( (~a).size() == b.size() ) );
4611 }
4612 //*************************************************************************************************
4613 
4614 
4615 //*************************************************************************************************
4627 template< typename VT // Type of the dense vector
4628  , bool AF // Alignment flag
4629  , bool TF > // Transpose flag
4631 {
4632  return ( isSame( a.vector_, b.vector_ ) && ( a.offset_ == b.offset_ ) && ( a.size_ == b.size_ ) );
4633 }
4634 //*************************************************************************************************
4635 
4636 
4637 //*************************************************************************************************
4652 template< typename VT // Type of the dense vector
4653  , bool AF // Alignment flag
4654  , bool TF > // Transpose flag
4655 inline typename DerestrictTrait< DenseSubvector<VT,AF,TF> >::Type
4656  derestrict( DenseSubvector<VT,AF,TF>& dv )
4657 {
4658  typedef typename DerestrictTrait< DenseSubvector<VT,AF,TF> >::Type ReturnType;
4659  return ReturnType( derestrict( dv.vector_ ), dv.offset_, dv.size_ );
4660 }
4662 //*************************************************************************************************
4663 
4664 
4665 
4666 
4667 //=================================================================================================
4668 //
4669 // GLOBAL RESTRUCTURING OPERATORS
4670 //
4671 //=================================================================================================
4672 
4673 //*************************************************************************************************
4686 template< bool AF1 // Required alignment flag
4687  , typename VT // Type of the dense vector
4688  , bool AF2 // Present alignment flag
4689  , bool TF > // Transpose flag
4690 inline const DenseSubvector<VT,AF1,TF>
4691  subvector( const DenseSubvector<VT,AF2,TF>& dv, size_t index, size_t size )
4692 {
4694 
4695  if( index + size > dv.size() )
4696  throw std::invalid_argument( "Invalid subvector specification" );
4697 
4698  return DenseSubvector<VT,AF1,TF>( dv.vector_, dv.offset_ + index, size );
4699 }
4701 //*************************************************************************************************
4702 
4703 
4704 
4705 
4706 //=================================================================================================
4707 //
4708 // ISRESTRICTED SPECIALIZATIONS
4709 //
4710 //=================================================================================================
4711 
4712 //*************************************************************************************************
4714 template< typename VT, bool AF, bool TF >
4715 struct IsRestricted< DenseSubvector<VT,AF,TF> > : public If< IsRestricted<VT>, TrueType, FalseType >::Type
4716 {
4717  enum { value = IsRestricted<VT>::value };
4718  typedef typename If< IsRestricted<VT>, TrueType, FalseType >::Type Type;
4719 };
4721 //*************************************************************************************************
4722 
4723 
4724 
4725 
4726 //=================================================================================================
4727 //
4728 // DERESTRICTTRAIT SPECIALIZATIONS
4729 //
4730 //=================================================================================================
4731 
4732 //*************************************************************************************************
4734 template< typename VT, bool AF, bool TF >
4735 struct DerestrictTrait< DenseSubvector<VT,AF,TF> >
4736 {
4737  typedef DenseSubvector< typename RemoveReference< typename DerestrictTrait<VT>::Type >::Type, AF, TF > Type;
4738 };
4740 //*************************************************************************************************
4741 
4742 
4743 
4744 
4745 //=================================================================================================
4746 //
4747 // HASCONSTDATAACCESS SPECIALIZATIONS
4748 //
4749 //=================================================================================================
4750 
4751 //*************************************************************************************************
4753 template< typename VT, bool AF, bool TF >
4754 struct HasConstDataAccess< DenseSubvector<VT,AF,TF> >
4755  : public If< HasConstDataAccess<VT>, TrueType, FalseType >::Type
4756 {
4757  enum { value = HasConstDataAccess<VT>::value };
4758  typedef typename If< HasConstDataAccess<VT>, TrueType, FalseType >::Type Type;
4759 };
4761 //*************************************************************************************************
4762 
4763 
4764 
4765 
4766 //=================================================================================================
4767 //
4768 // HASMUTABLEDATAACCESS SPECIALIZATIONS
4769 //
4770 //=================================================================================================
4771 
4772 //*************************************************************************************************
4774 template< typename VT, bool AF, bool TF >
4775 struct HasMutableDataAccess< DenseSubvector<VT,AF,TF> >
4776  : public If< HasMutableDataAccess<VT>, TrueType, FalseType >::Type
4777 {
4778  enum { value = HasMutableDataAccess<VT>::value };
4779  typedef typename If< HasMutableDataAccess<VT>, TrueType, FalseType >::Type Type;
4780 };
4782 //*************************************************************************************************
4783 
4784 
4785 
4786 
4787 //=================================================================================================
4788 //
4789 // SUBVECTORTRAIT SPECIALIZATIONS
4790 //
4791 //=================================================================================================
4792 
4793 //*************************************************************************************************
4795 template< typename VT, bool AF, bool TF >
4796 struct SubvectorTrait< DenseSubvector<VT,AF,TF> >
4797 {
4799 };
4801 //*************************************************************************************************
4802 
4803 
4804 
4805 
4806 //=================================================================================================
4807 //
4808 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
4809 //
4810 //=================================================================================================
4811 
4812 //*************************************************************************************************
4814 template< typename VT, bool AF1, bool TF, bool AF2 >
4815 struct SubvectorExprTrait< DenseSubvector<VT,AF1,TF>, AF2 >
4816 {
4817  typedef DenseSubvector<VT,AF2,TF> Type;
4818 };
4820 //*************************************************************************************************
4821 
4822 
4823 //*************************************************************************************************
4825 template< typename VT, bool AF1, bool TF, bool AF2 >
4826 struct SubvectorExprTrait< const DenseSubvector<VT,AF1,TF>, AF2 >
4827 {
4828  typedef DenseSubvector<VT,AF2,TF> Type;
4829 };
4831 //*************************************************************************************************
4832 
4833 
4834 //*************************************************************************************************
4836 template< typename VT, bool AF1, bool TF, bool AF2 >
4837 struct SubvectorExprTrait< volatile DenseSubvector<VT,AF1,TF>, AF2 >
4838 {
4839  typedef DenseSubvector<VT,AF2,TF> Type;
4840 };
4842 //*************************************************************************************************
4843 
4844 
4845 //*************************************************************************************************
4847 template< typename VT, bool AF1, bool TF, bool AF2 >
4848 struct SubvectorExprTrait< const volatile DenseSubvector<VT,AF1,TF>, AF2 >
4849 {
4850  typedef DenseSubvector<VT,AF2,TF> Type;
4851 };
4853 //*************************************************************************************************
4854 
4855 
4856 //*************************************************************************************************
4858 template< typename VT1, typename VT2, bool AF >
4859 struct SubvectorExprTrait< DVecDVecCrossExpr<VT1,VT2>, AF >
4860 {
4861  public:
4862  //**********************************************************************************************
4863  typedef DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4864  //**********************************************************************************************
4865 };
4867 //*************************************************************************************************
4868 
4869 
4870 //*************************************************************************************************
4872 template< typename VT1, typename VT2, bool AF >
4873 struct SubvectorExprTrait< DVecSVecCrossExpr<VT1,VT2>, AF >
4874 {
4875  public:
4876  //**********************************************************************************************
4877  typedef DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4878  //**********************************************************************************************
4879 };
4881 //*************************************************************************************************
4882 
4883 
4884 //*************************************************************************************************
4886 template< typename VT1, typename VT2, bool AF >
4887 struct SubvectorExprTrait< SVecDVecCrossExpr<VT1,VT2>, AF >
4888 {
4889  public:
4890  //**********************************************************************************************
4891  typedef DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4892  //**********************************************************************************************
4893 };
4895 //*************************************************************************************************
4896 
4897 
4898 //*************************************************************************************************
4900 template< typename VT1, typename VT2, bool AF >
4901 struct SubvectorExprTrait< SVecSVecCrossExpr<VT1,VT2>, AF >
4902 {
4903  public:
4904  //**********************************************************************************************
4905  typedef DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, unaligned, false > Type;
4906  //**********************************************************************************************
4907 };
4909 //*************************************************************************************************
4910 
4911 } // namespace blaze
4912 
4913 #endif
const ElementType * ConstPointer
Pointer to a constant subvector value.
Definition: DenseSubvector.h:422
Constraint on the data type.
const size_t final_
The final index for unaligned intrinsic operations.
Definition: DenseSubvector.h:982
Constraint on the data type.
BLAZE_ALWAYS_INLINE void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:879
bool canAlias(const Other *alias) const
Returns whether the dense subvector can alias with the given address alias.
Definition: DenseSubvector.h:1638
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the subvector/submatrix alignment flag values.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubvector.h:981
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:264
SubvectorIterator(IteratorType iterator, IteratorType finalIterator, size_t remainingElements, bool isMemoryAligned)
Constructor of the SubvectorIterator class.
Definition: DenseSubvector.h:478
SubvectorIterator()
Default constructor of the SubvectorIterator class.
Definition: DenseSubvector.h:462
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
IT::Type IntrinsicType
Intrinsic type of the subvector elements.
Definition: DenseSubvector.h:411
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:209
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:118
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
ReferenceType reference
Reference return type.
Definition: DenseSubvector.h:455
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:1562
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
bool isAligned_
Memory alignment flag.
Definition: DenseSubvector.h:778
Header file for the IsRowVector type trait.
const DenseSubvector & CompositeType
Data type for composite expression templates.
Definition: DenseSubvector.h:413
Header file for the DenseVector base class.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
SubvectorIterator(const SubvectorIterator< IteratorType2 > &it)
Conversion constructor from different SubvectorIterator instances.
Definition: DenseSubvector.h:493
Header file for the Computation base class.
IntrinsicType loadu() const
Unaligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:602
#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:626
DenseSubvector(Operand vector, size_t index, size_t n)
The constructor for DenseSubvector.
Definition: DenseSubvector.h:1059
IntrinsicTrait< typename VT::ElementType > IT
Intrinsic trait for the vector element type.
Definition: DenseSubvector.h:391
const size_t offset_
The offset of the subvector within the dense vector.
Definition: DenseSubvector.h:979
size_t capacity() const
Returns the maximum capacity of the dense subvector.
Definition: DenseSubvector.h:1544
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Iterator begin()
Returns an iterator to the first element of the subvector.
Definition: DenseSubvector.h:1162
DenseSubvector & operator=(const ElementType &rhs)
Homogenous assignment to all subvector elements.
Definition: DenseSubvector.h:1277
const bool aligned
Alignment flag for aligned subvectors and submatrices.
Definition: AlignmentFlag.h:83
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:123
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1904
Constraint on the data type.
void reset()
Reset to the default initial values.
Definition: DenseSubvector.h:1585
Pointer data()
Low-level data access to the subvector elements.
Definition: DenseSubvector.h:1128
DifferenceType difference_type
Difference between two iterators.
Definition: DenseSubvector.h:456
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:408
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:1838
Operand vector_
The dense vector containing the subvector.
Definition: DenseSubvector.h:978
const SubvectorIterator operator--(int)
Post-decrement operator.
Definition: DenseSubvector.h:562
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:76
Header file for nested template disabiguation.
Header file for the If class template.
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:1092
IfTrue< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a non-constant subvector value.
Definition: DenseSubvector.h:425
SubvectorIterator & operator++()
Pre-increment operator.
Definition: DenseSubvector.h:530
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
Header file for the Or class template.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type store(T *address, const sse_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Store.h:80
friend const SubvectorIterator operator-(const SubvectorIterator &it, size_t dec)
Subtraction between a SubvectorIterator and an integral value.
Definition: DenseSubvector.h:728
std::iterator_traits< IteratorType >::difference_type DifferenceType
Difference between two iterators.
Definition: DenseSubvector.h:449
ConstIterator cbegin() const
Returns an iterator to the first element of the subvector.
Definition: DenseSubvector.h:1198
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
DifferenceType operator-(const SubvectorIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DenseSubvector.h:692
VT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseSubvector.h:412
Header file for the subvector trait.
DenseSubvector< VT, AF, TF > This
Type of this DenseSubvector instance.
Definition: DenseSubvector.h:407
friend const SubvectorIterator operator+(size_t inc, const SubvectorIterator &it)
Addition between an integral value and a SubvectorIterator.
Definition: DenseSubvector.h:716
bool operator!=(const SubvectorIterator &rhs) const
Inequality comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:637
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:551
IteratorType iterator_
Iterator to the current subvector element.
Definition: DenseSubvector.h:775
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:79
IteratorType base() const
Access to the current position of the subvector iterator.
Definition: DenseSubvector.h:738
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
size_t size() const
Returns the current size/dimension of the dense subvector.
Definition: DenseSubvector.h:1529
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
Constraint on the data type.
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:2509
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseSubvector.h:409
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
Header file for the DerestrictTrait class template.
const bool unaligned
Alignment flag for unaligned subvectors and submatrices.
Definition: AlignmentFlag.h:63
std::iterator_traits< IteratorType >::iterator_category IteratorCategory
The iterator category.
Definition: DenseSubvector.h:437
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type load(const T *address)
Loads a vector of 2-byte integral values.
Definition: Load.h:79
Header file for the CrossExpr base class.
Header file for the IsNumeric type trait.
size_t rest_
The number of remaining elements beyond the final iterator.
Definition: DenseSubvector.h:777
Header file for the HasConstDataAccess type trait.
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
Header file for the IsConst type trait.
Iterator end()
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1216
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Base class for all subvectors.The Subvector class serves as a tag for all subvectors (i...
Definition: Subvector.h:64
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
View on a specific subvector of a dense vector.The DenseSubvector template represents a view on a spe...
Definition: DenseSubvector.h:382
SubvectorIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DenseSubvector.h:507
bool operator>(const SubvectorIterator &rhs) const
Greater-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:659
bool isAligned() const
Returns whether the subvector is properly aligned in memory.
Definition: DenseSubvector.h:1726
std::iterator_traits< IteratorType >::pointer PointerType
Pointer return type.
Definition: DenseSubvector.h:443
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:140
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storeu(T *address, const sse_int16_t &value)
Unaligned store of a vector of 2-byte integral values.
Definition: Storeu.h:77
ValueType value_type
Type of the underlying elements.
Definition: DenseSubvector.h:453
Header file for the AlignedArray implementation.
Header file for the cache size of the target architecture.
bool canSMPAssign() const
Returns whether the subvector can be used in SMP assignments.
Definition: DenseSubvector.h:1746
bool isAligned() const
Access to the iterator's memory alignment flag.
Definition: DenseSubvector.h:768
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2510
Header file for the isDefault shim.
ReferenceType operator*() const
Direct access to the element at the current iterator position.
Definition: DenseSubvector.h:572
IteratorType final() const
Access to the final position of the subvector iterator.
Definition: DenseSubvector.h:748
const size_t size_
The size of the subvector.
Definition: DenseSubvector.h:980
Header file for the HasMutableDataAccess type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:118
Evaluation of the return type of the derestrict function.Via this type trait it is possible to evalua...
Definition: DerestrictTrait.h:74
IntrinsicType load() const
Aligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:587
const SubvectorIterator operator++(int)
Post-increment operator.
Definition: DenseSubvector.h:541
IteratorCategory iterator_category
The iterator category.
Definition: DenseSubvector.h:452
Header file for the RemoveReference type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
size_t rest() const
Access to the number of remaining elements beyond the final iterator.
Definition: DenseSubvector.h:758
VT::ConstReference ConstReference
Reference to a constant subvector value.
Definition: DenseSubvector.h:416
SubvectorIterator< typename VT::ConstIterator > ConstIterator
Iterator over constant elements.
Definition: DenseSubvector.h:785
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:1794
friend const SubvectorIterator operator+(const SubvectorIterator &it, size_t inc)
Addition between a SubvectorIterator and an integral value.
Definition: DenseSubvector.h:704
bool isAliased(const Other *alias) const
Returns whether the dense subvector is aliased with the given address alias.
Definition: DenseSubvector.h:1683
#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:454
const bool isAligned_
Memory alignment flag.
Definition: DenseSubvector.h:987
If< IsExpression< VT >, VT, VT & >::Type Operand
Composite data type of the dense vector expression.
Definition: DenseSubvector.h:388
IteratorType final_
The final iterator for intrinsic operations.
Definition: DenseSubvector.h:776
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:1770
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:260
IfTrue< useConst, ConstIterator, SubvectorIterator< typename VT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseSubvector.h:788
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
bool operator>=(const SubvectorIterator &rhs) const
Greater-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:681
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
ConstIterator cend() const
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1252
Header file for the SubvectorExprTrait class template.
SubvectorIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DenseSubvector.h:519
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:432
IfTrue< useConst, ConstReference, typename VT::Reference >::Type Reference
Reference to a non-constant subvector value.
Definition: DenseSubvector.h:419
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
std::iterator_traits< IteratorType >::value_type ValueType
Type of the underlying elements.
Definition: DenseSubvector.h:440
VT::ElementType ElementType
Type of the subvector elements.
Definition: DenseSubvector.h:410
const size_t SMP_DVECASSIGN_THRESHOLD
SMP dense vector assignment threshold.This threshold specifies when an assignment of a simple dense v...
Definition: Thresholds.h:207
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1862
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:648
Header file for the IsRestricted type trait.
System settings for the inline keywords.
EnableIf< IsDenseVector< VT1 > >::Type smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:189
bool operator<=(const SubvectorIterator &rhs) const
Less-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:670
#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
Compile time type selection.The IfTrue class template selects one of the two given types T1 and T2 de...
Definition: If.h:59
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:446
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849