All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseSubvector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_DENSESUBVECTOR_H_
36 #define _BLAZE_MATH_VIEWS_DENSESUBVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <stdexcept>
56 #include <blaze/math/Intrinsics.h>
58 #include <blaze/math/shims/Reset.h>
68 #include <blaze/system/CacheSize.h>
69 #include <blaze/system/Streaming.h>
70 #include <blaze/util/Assert.h>
72 #include <blaze/util/DisableIf.h>
73 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/mpl/Or.h>
76 #include <blaze/util/SelectType.h>
77 #include <blaze/util/Template.h>
78 #include <blaze/util/Types.h>
82 
83 
84 namespace blaze {
85 
86 //=================================================================================================
87 //
88 // CLASS DEFINITION
89 //
90 //=================================================================================================
91 
92 //*************************************************************************************************
288 template< typename VT // Type of the dense vector
289  , bool TF = IsRowVector<VT>::value > // Transpose flag
290 class DenseSubvector : public DenseVector< DenseSubvector<VT,TF>, TF >
291  , private View
292 {
293  private:
294  //**Type definitions****************************************************************************
296  typedef typename SelectType< IsExpression<VT>::value, VT, VT& >::Type Operand;
297 
300  //**********************************************************************************************
301 
302  //**********************************************************************************************
304 
310  enum { useConst = IsConst<VT>::value };
311  //**********************************************************************************************
312 
313  public:
314  //**Type definitions****************************************************************************
318  typedef typename VT::ElementType ElementType;
319  typedef typename IT::Type IntrinsicType;
320  typedef typename VT::ReturnType ReturnType;
321  typedef const DenseSubvector& CompositeType;
322 
325 
328 
330  typedef const ElementType* ConstPointer;
331 
334  //**********************************************************************************************
335 
336  //**SubvectorIterator class definition**********************************************************
339  template< typename IteratorType > // Type of the dense vector iterator
341  {
342  public:
343  //**Type definitions*************************************************************************
345  typedef typename std::iterator_traits<IteratorType>::iterator_category IteratorCategory;
346 
348  typedef typename std::iterator_traits<IteratorType>::value_type ValueType;
349 
351  typedef typename std::iterator_traits<IteratorType>::pointer PointerType;
352 
354  typedef typename std::iterator_traits<IteratorType>::reference ReferenceType;
355 
357  typedef typename std::iterator_traits<IteratorType>::difference_type DifferenceType;
358 
359  // STL iterator requirements
365  //*******************************************************************************************
366 
367  //**Constructor******************************************************************************
375  explicit inline SubvectorIterator( IteratorType iterator, IteratorType final, size_t rest, bool aligned )
376  : iterator_( iterator ) // Iterator to the current subvector element
377  , final_ ( final ) // The final iterator for intrinsic operations
378  , rest_ ( rest ) // The number of remaining elements beyond the final iterator
379  , aligned_ ( aligned ) // Memory alignment flag
380  {}
381  //*******************************************************************************************
382 
383  //**Addition assignment operator*************************************************************
389  inline SubvectorIterator& operator+=( size_t inc ) {
390  iterator_ += inc;
391  return *this;
392  }
393  //*******************************************************************************************
394 
395  //**Subtraction assignment operator**********************************************************
401  inline SubvectorIterator& operator-=( size_t dec ) {
402  iterator_ -= dec;
403  return *this;
404  }
405  //*******************************************************************************************
406 
407  //**Prefix increment operator****************************************************************
413  ++iterator_;
414  return *this;
415  }
416  //*******************************************************************************************
417 
418  //**Postfix increment operator***************************************************************
423  inline const SubvectorIterator operator++( int ) {
425  }
426  //*******************************************************************************************
427 
428  //**Prefix decrement operator****************************************************************
434  --iterator_;
435  return *this;
436  }
437  //*******************************************************************************************
438 
439  //**Postfix decrement operator***************************************************************
444  inline const SubvectorIterator operator--( int ) {
446  }
447  //*******************************************************************************************
448 
449  //**Element access operator******************************************************************
454  inline ReferenceType operator*() const {
455  return *iterator_;
456  }
457  //*******************************************************************************************
458 
459  //**Load function****************************************************************************
469  inline IntrinsicType load() const {
470  return loadu();
471  }
472  //*******************************************************************************************
473 
474  //**Loadu function***************************************************************************
484  inline IntrinsicType loadu() const {
485  if( aligned_ ) {
486  return iterator_.load();
487  }
488  else if( iterator_ != final_ ) {
489  return iterator_.loadu();
490  }
491  else {
492  IntrinsicType value;
493  for( size_t j=0UL; j<rest_; ++j )
494  value[j] = *(iterator_+j);
495  return value;
496  }
497  }
498  //*******************************************************************************************
499 
500  //**Equality operator************************************************************************
506  inline bool operator==( const SubvectorIterator& rhs ) const {
507  return iterator_ == rhs.iterator_;
508  }
509  //*******************************************************************************************
510 
511  //**Inequality operator**********************************************************************
517  inline bool operator!=( const SubvectorIterator& rhs ) const {
518  return iterator_ != rhs.iterator_;
519  }
520  //*******************************************************************************************
521 
522  //**Less-than operator***********************************************************************
528  inline bool operator<( const SubvectorIterator& rhs ) const {
529  return iterator_ < rhs.iterator_;
530  }
531  //*******************************************************************************************
532 
533  //**Greater-than operator********************************************************************
539  inline bool operator>( const SubvectorIterator& rhs ) const {
540  return iterator_ > rhs.iterator_;
541  }
542  //*******************************************************************************************
543 
544  //**Less-or-equal-than operator**************************************************************
550  inline bool operator<=( const SubvectorIterator& rhs ) const {
551  return iterator_ <= rhs.iterator_;
552  }
553  //*******************************************************************************************
554 
555  //**Greater-or-equal-than operator***********************************************************
561  inline bool operator>=( const SubvectorIterator& rhs ) const {
562  return iterator_ >= rhs.iterator_;
563  }
564  //*******************************************************************************************
565 
566  //**Subtraction operator*********************************************************************
572  inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
573  return iterator_ - rhs.iterator_;
574  }
575  //*******************************************************************************************
576 
577  //**Addition operator************************************************************************
584  friend inline const SubvectorIterator operator+( const SubvectorIterator& it, size_t inc ) {
585  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.aligned_ );
586  }
587  //*******************************************************************************************
588 
589  //**Addition operator************************************************************************
596  friend inline const SubvectorIterator operator+( size_t inc, const SubvectorIterator& it ) {
597  return SubvectorIterator( it.iterator_ + inc, it.final_, it.rest_, it.aligned_ );
598  }
599  //*******************************************************************************************
600 
601  //**Subtraction operator*********************************************************************
608  friend inline const SubvectorIterator operator-( const SubvectorIterator& it, size_t dec ) {
609  return SubvectorIterator( it.iterator_ - dec, it.final_, it.rest_, it.aligned_ );
610  }
611  //*******************************************************************************************
612 
613  private:
614  //**Member variables*************************************************************************
615  IteratorType iterator_;
616  IteratorType final_;
617  size_t rest_;
618  bool aligned_;
619  //*******************************************************************************************
620  };
621  //**********************************************************************************************
622 
623  //**Type definitions****************************************************************************
626 
629  //**********************************************************************************************
630 
631  //**Compilation flags***************************************************************************
633  enum { vectorizable = VT::vectorizable };
634 
636  enum { smpAssignable = VT::smpAssignable };
637  //**********************************************************************************************
638 
639  //**Constructors********************************************************************************
642  explicit inline DenseSubvector( VT& vector, size_t index, size_t n );
643  // No explicitly declared copy constructor.
645  //**********************************************************************************************
646 
647  //**Destructor**********************************************************************************
648  // No explicitly declared destructor.
649  //**********************************************************************************************
650 
651  //**Data access functions***********************************************************************
654  inline Reference operator[]( size_t index );
655  inline ConstReference operator[]( size_t index ) const;
656  inline Pointer data ();
657  inline ConstPointer data () const;
658  inline Iterator begin ();
659  inline ConstIterator begin () const;
660  inline ConstIterator cbegin() const;
661  inline Iterator end ();
662  inline ConstIterator end () const;
663  inline ConstIterator cend () const;
665  //**********************************************************************************************
666 
667  //**Assignment operators************************************************************************
670  inline DenseSubvector& operator= ( const ElementType& rhs );
671  inline DenseSubvector& operator= ( const DenseSubvector& rhs );
672  template< typename VT2 > inline DenseSubvector& operator= ( const Vector<VT2,TF>& rhs );
673  template< typename VT2 > inline DenseSubvector& operator+=( const Vector<VT2,TF>& rhs );
674  template< typename VT2 > inline DenseSubvector& operator-=( const Vector<VT2,TF>& rhs );
675  template< typename VT2 > inline DenseSubvector& operator*=( const Vector<VT2,TF>& rhs );
676 
677  template< typename Other >
678  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
679  operator*=( Other rhs );
680 
681  template< typename Other >
682  inline typename EnableIf< IsNumeric<Other>, DenseSubvector >::Type&
683  operator/=( Other rhs );
685  //**********************************************************************************************
686 
687  //**Utility functions***************************************************************************
690  inline size_t size() const;
691  inline size_t capacity() const;
692  inline size_t nonZeros() const;
693  inline void reset();
694  template< typename Other > inline DenseSubvector& scale( const Other& scalar );
696  //**********************************************************************************************
697 
698  private:
699  //**********************************************************************************************
701  template< typename VT2 >
703  struct VectorizedAssign {
704  enum { value = vectorizable && VT2::vectorizable &&
705  IsSame<ElementType,typename VT2::ElementType>::value };
706  };
708  //**********************************************************************************************
709 
710  //**********************************************************************************************
712  template< typename VT2 >
714  struct VectorizedAddAssign {
715  enum { value = vectorizable && VT2::vectorizable &&
716  IsSame<ElementType,typename VT2::ElementType>::value &&
717  IntrinsicTrait<ElementType>::addition };
718  };
720  //**********************************************************************************************
721 
722  //**********************************************************************************************
724  template< typename VT2 >
726  struct VectorizedSubAssign {
727  enum { value = vectorizable && VT2::vectorizable &&
728  IsSame<ElementType,typename VT2::ElementType>::value &&
729  IntrinsicTrait<ElementType>::subtraction };
730  };
732  //**********************************************************************************************
733 
734  //**********************************************************************************************
736  template< typename VT2 >
738  struct VectorizedMultAssign {
739  enum { value = vectorizable && VT2::vectorizable &&
740  IsSame<ElementType,typename VT2::ElementType>::value &&
741  IntrinsicTrait<ElementType>::multiplication };
742  };
744  //**********************************************************************************************
745 
746  public:
747  //**Expression template evaluation functions****************************************************
750  template< typename Other > inline bool canAlias ( const Other* alias ) const;
751  template< typename Other > inline bool isAliased( const Other* alias ) const;
752 
753  inline IntrinsicType load ( size_t index ) const;
754  inline IntrinsicType loadu ( size_t index ) const;
755  inline void store ( size_t index, const IntrinsicType& value );
756  inline void storeu( size_t index, const IntrinsicType& value );
757  inline void stream( size_t index, const IntrinsicType& value );
758 
759  template< typename VT2 >
760  inline typename DisableIf< VectorizedAssign<VT2> >::Type
761  assign( const DenseVector <VT2,TF>& rhs );
762 
763  template< typename VT2 >
764  inline typename EnableIf< VectorizedAssign<VT2> >::Type
765  assign( const DenseVector <VT2,TF>& rhs );
766 
767  template< typename VT2 > inline void assign( const SparseVector<VT2,TF>& rhs );
768 
769  template< typename VT2 >
770  inline typename DisableIf< VectorizedAddAssign<VT2> >::Type
771  addAssign( const DenseVector <VT2,TF>& rhs );
772 
773  template< typename VT2 >
774  inline typename EnableIf< VectorizedAddAssign<VT2> >::Type
775  addAssign ( const DenseVector <VT2,TF>& rhs );
776 
777  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
778 
779  template< typename VT2 >
780  inline typename DisableIf< VectorizedSubAssign<VT2> >::Type
781  subAssign ( const DenseVector <VT2,TF>& rhs );
782 
783  template< typename VT2 >
784  inline typename EnableIf< VectorizedSubAssign<VT2> >::Type
785  subAssign( const DenseVector <VT2,TF>& rhs );
786 
787  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
788 
789  template< typename VT2 >
790  inline typename DisableIf< VectorizedMultAssign<VT2> >::Type
791  multAssign( const DenseVector <VT2,TF>& rhs );
792 
793  template< typename VT2 >
794  inline typename EnableIf< VectorizedMultAssign<VT2> >::Type
795  multAssign( const DenseVector <VT2,TF>& rhs );
796 
797  template< typename VT2 > inline void multAssign( const SparseVector<VT2,TF>& rhs );
799  //**********************************************************************************************
800 
801  private:
802  //**Member variables****************************************************************************
806  const size_t offset_;
807  const size_t size_;
808  const size_t rest_;
809  const size_t final_;
810 
814  const bool aligned_;
815 
825  //**********************************************************************************************
826 
827  //**Friend declarations*************************************************************************
829  template< typename VT2, bool TF2 >
830  friend DenseSubvector<VT2,TF2> subvector( const DenseSubvector<VT2,TF2>& dv, size_t index, size_t size );
832  //**********************************************************************************************
833 
834  //**Compile time checks*************************************************************************
841  //**********************************************************************************************
842 };
843 //*************************************************************************************************
844 
845 
846 
847 
848 //=================================================================================================
849 //
850 // CONSTRUCTOR
851 //
852 //=================================================================================================
853 
854 //*************************************************************************************************
866 template< typename VT // Type of the dense vector
867  , bool TF > // Transpose flag
868 inline DenseSubvector<VT,TF>::DenseSubvector( VT& vector, size_t index, size_t n )
869  : vector_ ( vector ) // The vector containing the subvector
870  , offset_ ( index ) // The offset of the subvector within the dense vector
871  , size_ ( n ) // The size of the subvector
872  , rest_ ( n % IT::size ) // The number of remaining elements in an unaligned intrinsic operation
873  , final_ ( n - rest_ ) // The final index for unaligned intrinsic operations
874  , aligned_( ( index % IT::size == 0UL ) &&
875  ( index + n == vector.size() || n % IT::size == 0UL ) )
876 {
877  if( index + n > vector.size() )
878  throw std::invalid_argument( "Invalid subvector specification" );
879 }
880 //*************************************************************************************************
881 
882 
883 
884 
885 //=================================================================================================
886 //
887 // DATA ACCESS FUNCTIONS
888 //
889 //=================================================================================================
890 
891 //*************************************************************************************************
897 template< typename VT // Type of the dense vector
898  , bool TF > // Transpose flag
899 inline typename DenseSubvector<VT,TF>::Reference
901 {
902  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
903  return vector_[offset_+index];
904 }
905 //*************************************************************************************************
906 
907 
908 //*************************************************************************************************
914 template< typename VT // Type of the dense vector
915  , bool TF > // Transpose flag
917  DenseSubvector<VT,TF>::operator[]( size_t index ) const
918 {
919  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
920  return const_cast<const VT&>( vector_ )[offset_+index];
921 }
922 //*************************************************************************************************
923 
924 
925 //*************************************************************************************************
932 template< typename VT // Type of the dense vector
933  , bool TF > // Transpose flag
935 {
936  return vector_.data() + offset_;
937 }
938 //*************************************************************************************************
939 
940 
941 //*************************************************************************************************
948 template< typename VT // Type of the dense vector
949  , bool TF > // Transpose flag
951 {
952  return vector_.data() + offset_;
953 }
954 //*************************************************************************************************
955 
956 
957 //*************************************************************************************************
964 template< typename VT // Type of the dense vector
965  , bool TF > // Transpose flag
967 {
968  const typename VT::Iterator first( vector_.begin() + offset_ );
969  return Iterator( first, first + final_, rest_, aligned_ );
970 }
971 //*************************************************************************************************
972 
973 
974 //*************************************************************************************************
981 template< typename VT // Type of the dense vector
982  , bool TF > // Transpose flag
984 {
985  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
986  return ConstIterator( first, first + final_, rest_, aligned_ );
987 }
988 //*************************************************************************************************
989 
990 
991 //*************************************************************************************************
998 template< typename VT // Type of the dense vector
999  , bool TF > // Transpose flag
1001 {
1002  const typename VT::ConstIterator first( vector_.cbegin() + offset_ );
1003  return ConstIterator( first, first + final_, rest_, aligned_ );
1004 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1015 template< typename VT // Type of the dense vector
1016  , bool TF > // Transpose flag
1018 {
1019  const typename VT::Iterator last( vector_.begin() + offset_ + size_ );
1020  return Iterator( last, last, rest_, aligned_ );
1021 }
1022 //*************************************************************************************************
1023 
1024 
1025 //*************************************************************************************************
1032 template< typename VT // Type of the dense vector
1033  , bool TF > // Transpose flag
1035 {
1036  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1037  return ConstIterator( last, last, rest_, aligned_ );
1038 }
1039 //*************************************************************************************************
1040 
1041 
1042 //*************************************************************************************************
1049 template< typename VT // Type of the dense vector
1050  , bool TF > // Transpose flag
1052 {
1053  const typename VT::ConstIterator last( vector_.cbegin() + offset_ + size_ );
1054  return ConstIterator( last, last, rest_, aligned_ );
1055 }
1056 //*************************************************************************************************
1057 
1058 
1059 
1060 
1061 //=================================================================================================
1062 //
1063 // ASSIGNMENT OPERATORS
1064 //
1065 //=================================================================================================
1066 
1067 //*************************************************************************************************
1073 template< typename VT // Type of the dense vector
1074  , bool TF > // Transpose flag
1076 {
1077  const size_t iend( offset_ + size_ );
1078 
1079  for( size_t i=offset_; i<iend; ++i )
1080  vector_[i] = rhs;
1081 
1082  return *this;
1083 }
1084 //*************************************************************************************************
1085 
1086 
1087 //*************************************************************************************************
1097 template< typename VT // Type of the dense vector
1098  , bool TF > // Transpose flag
1100 {
1101  using blaze::assign;
1102 
1105 
1106  if( &rhs == this || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
1107  return *this;
1108 
1109  if( size() != rhs.size() )
1110  throw std::invalid_argument( "Subvector sizes do not match" );
1111 
1112  if( rhs.canAlias( &vector_ ) ) {
1113  const ResultType tmp( ~rhs );
1114  assign( *this, tmp );
1115  }
1116  else {
1117  assign( *this, rhs );
1118  }
1119 
1120  return *this;
1121 }
1122 //*************************************************************************************************
1123 
1124 
1125 //*************************************************************************************************
1135 template< typename VT // Type of the dense vector
1136  , bool TF > // Transpose flag
1137 template< typename VT2 > // Type of the right-hand side vector
1139 {
1140  using blaze::assign;
1141 
1144 
1145  if( size() != (~rhs).size() )
1146  throw std::invalid_argument( "Vector sizes do not match" );
1147 
1148  if( (~rhs).canAlias( &vector_ ) ) {
1149  const typename VT2::ResultType tmp( ~rhs );
1150  assign( *this, tmp );
1151  }
1152  else {
1154  reset();
1155  assign( *this, ~rhs );
1156  }
1157 
1158  return *this;
1159 }
1160 //*************************************************************************************************
1161 
1162 
1163 //*************************************************************************************************
1173 template< typename VT // Type of the dense vector
1174  , bool TF > // Transpose flag
1175 template< typename VT2 > // Type of the right-hand side vector
1177 {
1178  using blaze::addAssign;
1179 
1182 
1183  if( size() != (~rhs).size() )
1184  throw std::invalid_argument( "Vector sizes do not match" );
1185 
1186  if( (~rhs).canAlias( &vector_ ) ) {
1187  const typename VT2::ResultType tmp( ~rhs );
1188  addAssign( *this, tmp );
1189  }
1190  else {
1191  addAssign( *this, ~rhs );
1192  }
1193 
1194  return *this;
1195 }
1196 //*************************************************************************************************
1197 
1198 
1199 //*************************************************************************************************
1209 template< typename VT // Type of the dense vector
1210  , bool TF > // Transpose flag
1211 template< typename VT2 > // Type of the right-hand side vector
1213 {
1214  using blaze::subAssign;
1215 
1218 
1219  if( size() != (~rhs).size() )
1220  throw std::invalid_argument( "Vector sizes do not match" );
1221 
1222  if( (~rhs).canAlias( &vector_ ) ) {
1223  const typename VT2::ResultType tmp( ~rhs );
1224  subAssign( *this, tmp );
1225  }
1226  else {
1227  subAssign( *this, ~rhs );
1228  }
1229 
1230  return *this;
1231 }
1232 //*************************************************************************************************
1233 
1234 
1235 //*************************************************************************************************
1246 template< typename VT // Type of the dense vector
1247  , bool TF > // Transpose flag
1248 template< typename VT2 > // Type of the right-hand side vector
1250 {
1251  using blaze::multAssign;
1252 
1255 
1256  if( size() != (~rhs).size() )
1257  throw std::invalid_argument( "Vector sizes do not match" );
1258 
1259  if( (~rhs).canAlias( &vector_ ) || IsSparseVector<VT2>::value ) {
1260  const typename VT2::ResultType tmp( ~rhs );
1261  multAssign( *this, tmp );
1262  }
1263  else {
1264  multAssign( *this, ~rhs );
1265  }
1266 
1267  return *this;
1268 }
1269 //*************************************************************************************************
1270 
1271 
1272 //*************************************************************************************************
1279 template< typename VT // Type of the dense vector
1280  , bool TF > // Transpose flag
1281 template< typename Other > // Data type of the right-hand side scalar
1282 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,TF> >::Type&
1284 {
1285  return operator=( (*this) * rhs );
1286 }
1287 //*************************************************************************************************
1288 
1289 
1290 //*************************************************************************************************
1299 template< typename VT // Type of the dense vector
1300  , bool TF > // Transpose flag
1301 template< typename Other > // Data type of the right-hand side scalar
1302 inline typename EnableIf< IsNumeric<Other>, DenseSubvector<VT,TF> >::Type&
1304 {
1305  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1306 
1307  return operator=( (*this) / rhs );
1308 }
1309 //*************************************************************************************************
1310 
1311 
1312 
1313 
1314 //=================================================================================================
1315 //
1316 // UTILITY FUNCTIONS
1317 //
1318 //=================================================================================================
1319 
1320 //*************************************************************************************************
1325 template< typename VT // Type of the dense vector
1326  , bool TF > // Transpose flag
1327 inline size_t DenseSubvector<VT,TF>::size() const
1328 {
1329  return size_;
1330 }
1331 //*************************************************************************************************
1332 
1333 
1334 //*************************************************************************************************
1339 template< typename VT // Type of the dense vector
1340  , bool TF > // Transpose flag
1341 inline size_t DenseSubvector<VT,TF>::capacity() const
1342 {
1343  return vector_.capacity() - offset_;
1344 }
1345 //*************************************************************************************************
1346 
1347 
1348 //*************************************************************************************************
1356 template< typename VT // Type of the dense vector
1357  , bool TF > // Transpose flag
1358 inline size_t DenseSubvector<VT,TF>::nonZeros() const
1359 {
1360  size_t nonzeros( 0 );
1361 
1362  const size_t iend( offset_ + size_ );
1363  for( size_t i=offset_; i<iend; ++i ) {
1364  if( !isDefault( vector_[i] ) )
1365  ++nonzeros;
1366  }
1367 
1368  return nonzeros;
1369 }
1370 //*************************************************************************************************
1371 
1372 
1373 //*************************************************************************************************
1378 template< typename VT // Type of the dense vector
1379  , bool TF > // Transpose flag
1381 {
1382  using blaze::reset;
1383 
1384  const size_t iend( offset_ + size_ );
1385  for( size_t i=offset_; i<iend; ++i )
1386  reset( vector_[i] );
1387 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1397 template< typename VT // Type of the dense vector
1398  , bool TF > // Transpose flag
1399 template< typename Other > // Data type of the scalar value
1401 {
1402  const size_t iend( offset_ + size_ );
1403  for( size_t i=offset_; i<iend; ++i )
1404  vector_[i] *= scalar;
1405  return *this;
1406 }
1407 //*************************************************************************************************
1408 
1409 
1410 
1411 
1412 //=================================================================================================
1413 //
1414 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1415 //
1416 //=================================================================================================
1417 
1418 //*************************************************************************************************
1428 template< typename VT // Type of the dense vector
1429  , bool TF > // Transpose flag
1430 template< typename Other > // Data type of the foreign expression
1431 inline bool DenseSubvector<VT,TF>::canAlias( const Other* alias ) const
1432 {
1433  return static_cast<const void*>( &vector_ ) == static_cast<const void*>( alias );
1434 }
1435 //*************************************************************************************************
1436 
1437 
1438 //*************************************************************************************************
1448 template< typename VT // Type of the dense vector
1449  , bool TF > // Transpose flag
1450 template< typename Other > // Data type of the foreign expression
1451 inline bool DenseSubvector<VT,TF>::isAliased( const Other* alias ) const
1452 {
1453  return static_cast<const void*>( &vector_ ) == static_cast<const void*>( alias );
1454 }
1455 //*************************************************************************************************
1456 
1457 
1458 //*************************************************************************************************
1471 template< typename VT // Type of the dense vector
1472  , bool TF > // Transpose flag
1474  DenseSubvector<VT,TF>::load( size_t index ) const
1475 {
1476  return loadu( index );
1477 }
1478 //*************************************************************************************************
1479 
1480 
1481 //*************************************************************************************************
1494 template< typename VT // Type of the dense vector
1495  , bool TF > // Transpose flag
1497  DenseSubvector<VT,TF>::loadu( size_t index ) const
1498 {
1500 
1501  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1502  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1503 
1504  if( aligned_ || index != final_ ) {
1505  return vector_.loadu( offset_+index );
1506  }
1507  else {
1508  IntrinsicType value;
1509  for( size_t j=0UL; j<rest_; ++j )
1510  value[j] = vector_[offset_+index+j];
1511  return value;
1512  }
1513 }
1514 //*************************************************************************************************
1515 
1516 
1517 //*************************************************************************************************
1531 template< typename VT // Type of the dense vector
1532  , bool TF > // Transpose flag
1533 inline void DenseSubvector<VT,TF>::store( size_t index, const IntrinsicType& value )
1534 {
1535  storeu( index, value );
1536 }
1537 //*************************************************************************************************
1538 
1539 
1540 //*************************************************************************************************
1554 template< typename VT // Type of the dense vector
1555  , bool TF > // Transpose flag
1556 inline void DenseSubvector<VT,TF>::storeu( size_t index, const IntrinsicType& value )
1557 {
1559 
1560  BLAZE_INTERNAL_ASSERT( index < size() , "Invalid subvector access index" );
1561  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid subvector access index" );
1562 
1563  if( aligned_ || index != final_ ) {
1564  vector_.storeu( offset_+index, value );
1565  }
1566  else {
1567  for( size_t j=0UL; j<rest_; ++j )
1568  vector_[offset_+index+j] = value[j];
1569  }
1570 }
1571 //*************************************************************************************************
1572 
1573 
1574 //*************************************************************************************************
1588 template< typename VT // Type of the dense vector
1589  , bool TF > // Transpose flag
1590 inline void DenseSubvector<VT,TF>::stream( size_t index, const IntrinsicType& value )
1591 {
1592  storeu( index, value );
1593 }
1594 //*************************************************************************************************
1595 
1596 
1597 //*************************************************************************************************
1608 template< typename VT // Type of the dense vector
1609  , bool TF > // Transpose flag
1610 template< typename VT2 > // Type of the right-hand side dense vector
1611 inline typename DisableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1613 {
1614  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1615 
1616  const size_t iend( size() & size_t(-2) );
1617  for( size_t i=0UL; i<iend; i+=2UL ) {
1618  vector_[i+offset_ ] = (~rhs)[i ];
1619  vector_[i+offset_+1UL] = (~rhs)[i+1UL];
1620  }
1621  if( iend < size() ) {
1622  vector_[iend+offset_] = (~rhs)[iend];
1623  }
1624 }
1625 //*************************************************************************************************
1626 
1627 
1628 //*************************************************************************************************
1639 template< typename VT // Type of the dense vector
1640  , bool TF > // Transpose flag
1641 template< typename VT2 > // Type of the right-hand side dense vector
1642 inline typename EnableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedAssign<VT2> >::Type
1644 {
1645  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1646 
1648 
1649  if( useStreaming && aligned_ &&
1650  ( size_ > ( cacheSize/( sizeof(ElementType) * 3UL ) ) ) &&
1651  !(~rhs).isAliased( &vector_ ) )
1652  {
1653  for( size_t i=0UL; i<size(); i+=IT::size ) {
1654  vector_.stream( offset_+i, (~rhs).load(i) );
1655  }
1656  }
1657  else
1658  {
1659  const size_t iend( size_ & size_t(-IT::size*4) );
1660  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1661 
1662  typename VT2::ConstIterator it( (~rhs).begin() );
1663  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1664  vector_.storeu( offset_+i , it.load() ); it += IT::size;
1665  vector_.storeu( offset_+i+IT::size , it.load() ); it += IT::size;
1666  vector_.storeu( offset_+i+IT::size*2UL, it.load() ); it += IT::size;
1667  vector_.storeu( offset_+i+IT::size*3UL, it.load() ); it += IT::size;
1668  }
1669  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1670  storeu( i, it.load() );
1671  }
1672  }
1673 }
1674 //*************************************************************************************************
1675 
1676 
1677 //*************************************************************************************************
1688 template< typename VT // Type of the dense vector
1689  , bool TF > // Transpose flag
1690 template< typename VT2 > // Type of the right-hand side dense vector
1692 {
1693  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1694 
1695  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1696  vector_[element->index()+offset_] = element->value();
1697 }
1698 //*************************************************************************************************
1699 
1700 
1701 //*************************************************************************************************
1712 template< typename VT // Type of the dense vector
1713  , bool TF > // Transpose flag
1714 template< typename VT2 > // Type of the right-hand side dense vector
1715 inline typename DisableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
1717 {
1718  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1719 
1720  const size_t iend( size() & size_t(-2) );
1721  for( size_t i=0UL; i<iend; i+=2UL ) {
1722  vector_[i+offset_ ] += (~rhs)[i ];
1723  vector_[i+offset_+1UL] += (~rhs)[i+1UL];
1724  }
1725  if( iend < size() ) {
1726  vector_[iend+offset_] += (~rhs)[iend];
1727  }
1728 }
1729 //*************************************************************************************************
1730 
1731 
1732 //*************************************************************************************************
1743 template< typename VT // Type of the dense vector
1744  , bool TF > // Transpose flag
1745 template< typename VT2 > // Type of the right-hand side dense vector
1746 inline typename EnableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedAddAssign<VT2> >::Type
1748 {
1749  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1750 
1752 
1753  const size_t iend( size_ & size_t(-IT::size*4) );
1754  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1755 
1756  typename VT2::ConstIterator it( (~rhs).begin() );
1757  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1758  vector_.storeu( offset_+i , load(i ) + it.load() ); it += IT::size;
1759  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) + it.load() ); it += IT::size;
1760  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) + it.load() ); it += IT::size;
1761  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) + it.load() ); it += IT::size;
1762  }
1763  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1764  storeu( i, load(i) + it.load() );
1765  }
1766 }
1767 //*************************************************************************************************
1768 
1769 
1770 //*************************************************************************************************
1781 template< typename VT // Type of the dense vector
1782  , bool TF > // Transpose flag
1783 template< typename VT2 > // Type of the right-hand side dense vector
1785 {
1786  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1787 
1788  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1789  vector_[element->index()+offset_] += element->value();
1790 }
1791 //*************************************************************************************************
1792 
1793 
1794 //*************************************************************************************************
1805 template< typename VT // Type of the dense vector
1806  , bool TF > // Transpose flag
1807 template< typename VT2 > // Type of the right-hand side dense vector
1808 inline typename DisableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
1810 {
1811  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1812 
1813  const size_t iend( size() & size_t(-2) );
1814  for( size_t i=0UL; i<iend; i+=2UL ) {
1815  vector_[i+offset_ ] -= (~rhs)[i ];
1816  vector_[i+offset_+1UL] -= (~rhs)[i+1UL];
1817  }
1818  if( iend < size() ) {
1819  vector_[iend+offset_] -= (~rhs)[iend];
1820  }
1821 }
1822 //*************************************************************************************************
1823 
1824 
1825 //*************************************************************************************************
1836 template< typename VT // Type of the dense vector
1837  , bool TF > // Transpose flag
1838 template< typename VT2 > // Type of the right-hand side dense vector
1839 inline typename EnableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedSubAssign<VT2> >::Type
1841 {
1842  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1843 
1845 
1846  const size_t iend( size_ & size_t(-IT::size*4) );
1847  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1848 
1849  typename VT2::ConstIterator it( (~rhs).begin() );
1850  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1851  vector_.storeu( offset_+i , load(i ) - it.load() ); it += IT::size;
1852  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) - it.load() ); it += IT::size;
1853  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) - it.load() ); it += IT::size;
1854  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) - it.load() ); it += IT::size;
1855  }
1856  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1857  storeu( i, load(i) - it.load() );
1858  }
1859 }
1860 //*************************************************************************************************
1861 
1862 
1863 //*************************************************************************************************
1874 template< typename VT // Type of the dense vector
1875  , bool TF > // Transpose flag
1876 template< typename VT2 > // Type of the right-hand side dense vector
1878 {
1879  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1880 
1881  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1882  vector_[element->index()+offset_] -= element->value();
1883 }
1884 //*************************************************************************************************
1885 
1886 
1887 //*************************************************************************************************
1898 template< typename VT // Type of the dense vector
1899  , bool TF > // Transpose flag
1900 template< typename VT2 > // Type of the right-hand side dense vector
1901 inline typename DisableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
1903 {
1904  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1905 
1906  const size_t iend( size() & size_t(-2) );
1907  for( size_t i=0UL; i<iend; i+=2UL ) {
1908  vector_[i+offset_ ] *= (~rhs)[i ];
1909  vector_[i+offset_+1UL] *= (~rhs)[i+1UL];
1910  }
1911  if( iend < size() ) {
1912  vector_[iend+offset_] *= (~rhs)[iend];
1913  }
1914 }
1915 //*************************************************************************************************
1916 
1917 
1918 //*************************************************************************************************
1929 template< typename VT // Type of the dense vector
1930  , bool TF > // Transpose flag
1931 template< typename VT2 > // Type of the right-hand side dense vector
1932 inline typename EnableIf< typename DenseSubvector<VT,TF>::BLAZE_TEMPLATE VectorizedMultAssign<VT2> >::Type
1934 {
1935  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1936 
1938 
1939  const size_t iend( size_ & size_t(-IT::size*4) );
1940  BLAZE_INTERNAL_ASSERT( ( size_ - ( size_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
1941 
1942  typename VT2::ConstIterator it( (~rhs).begin() );
1943  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
1944  vector_.storeu( offset_+i , load(i ) * it.load() ); it += IT::size;
1945  vector_.storeu( offset_+i+IT::size , load(i+IT::size ) * it.load() ); it += IT::size;
1946  vector_.storeu( offset_+i+IT::size*2UL, load(i+IT::size*2UL) * it.load() ); it += IT::size;
1947  vector_.storeu( offset_+i+IT::size*3UL, load(i+IT::size*3UL) * it.load() ); it += IT::size;
1948  }
1949  for( size_t i=iend; i<size_; i+=IT::size, it+=IT::size ) {
1950  storeu( i, load(i) * it.load() );
1951  }
1952 }
1953 //*************************************************************************************************
1954 
1955 
1956 //*************************************************************************************************
1967 template< typename VT // Type of the dense vector
1968  , bool TF > // Transpose flag
1969 template< typename VT2 > // Type of the right-hand side dense vector
1971 {
1972  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1973 
1974  const ResultType tmp( *this );
1975 
1976  reset();
1977 
1978  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1979  vector_[element->index()+offset_] = tmp[element->index()] * element->value();
1980 }
1981 //*************************************************************************************************
1982 
1983 
1984 
1985 
1986 
1987 
1988 
1989 
1990 //=================================================================================================
1991 //
1992 // CLASS TEMPLATE SPECIALIZATION FOR DVECDVECCROSSEXPR
1993 //
1994 //=================================================================================================
1995 
1996 //*************************************************************************************************
2004 template< typename VT1 // Type of the left-hand side dense vector
2005  , typename VT2 > // Type of the right-hand side dense vector
2006 class DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, false >
2007  : public DenseVector< DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, false >, false >
2008  , private View
2009 {
2010  private:
2011  //**Type definitions****************************************************************************
2012  typedef DVecDVecCrossExpr<VT1,VT2> CPE;
2013  typedef typename CPE::ResultType RT;
2014  //**********************************************************************************************
2015 
2016  public:
2017  //**Type definitions****************************************************************************
2019  typedef typename SubvectorTrait<RT>::Type ResultType;
2020  typedef typename ResultType::TransposeType TransposeType;
2021  typedef typename CPE::ElementType ElementType;
2022  typedef typename CPE::ReturnType ReturnType;
2023  typedef const ResultType CompositeType;
2024  //**********************************************************************************************
2025 
2026  //**Compilation flags***************************************************************************
2028  enum { vectorizable = 0 };
2029  //**********************************************************************************************
2030 
2031  //**Constructor*********************************************************************************
2038  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
2039  : vector_( vector ) // The dense vector/dense vector cross product expression
2040  , offset_( index ) // The offset of the subvector within the cross product expression
2041  , size_ ( n ) // The size of the subvector
2042  {}
2043  //**********************************************************************************************
2044 
2045  //**Subscript operator**************************************************************************
2051  inline ReturnType operator[]( size_t index ) const {
2052  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2053  return vector_[offset_+index];
2054  }
2055  //**********************************************************************************************
2056 
2057  //**Size function*******************************************************************************
2062  inline size_t size() const {
2063  return size_;
2064  }
2065  //**********************************************************************************************
2066 
2067  //**********************************************************************************************
2073  template< typename T >
2074  inline bool canAlias( const T* alias ) const {
2075  return vector_.canAlias( alias );
2076  }
2077  //**********************************************************************************************
2078 
2079  //**********************************************************************************************
2085  template< typename T >
2086  inline bool isAliased( const T* alias ) const {
2087  return vector_.isAliased( alias );
2088  }
2089  //**********************************************************************************************
2090 
2091  private:
2092  //**Member variables****************************************************************************
2095  CPE vector_;
2096  const size_t offset_;
2097  const size_t size_;
2098 
2099  //**********************************************************************************************
2100 
2101  //**Friend declarations*************************************************************************
2102  template< typename VT, bool TF >
2103  friend DenseSubvector<VT,TF> subvector( const DenseSubvector<VT,TF>& dv, size_t index, size_t size );
2104  //**********************************************************************************************
2105 };
2107 //*************************************************************************************************
2108 
2109 
2110 
2111 
2112 
2113 
2114 
2115 
2116 //=================================================================================================
2117 //
2118 // CLASS TEMPLATE SPECIALIZATION FOR DVECSVECCROSSEXPR
2119 //
2120 //=================================================================================================
2121 
2122 //*************************************************************************************************
2130 template< typename VT1 // Type of the left-hand side dense vector
2131  , typename VT2 > // Type of the right-hand side sparse vector
2132 class DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, false >
2133  : public DenseVector< DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, false >, false >
2134  , private View
2135 {
2136  private:
2137  //**Type definitions****************************************************************************
2138  typedef DVecSVecCrossExpr<VT1,VT2> CPE;
2139  typedef typename CPE::ResultType RT;
2140  //**********************************************************************************************
2141 
2142  public:
2143  //**Type definitions****************************************************************************
2144  typedef DenseSubvector<CPE,false> This;
2145  typedef typename SubvectorTrait<RT>::Type ResultType;
2146  typedef typename ResultType::TransposeType TransposeType;
2147  typedef typename CPE::ElementType ElementType;
2148  typedef typename CPE::ReturnType ReturnType;
2149  typedef const ResultType CompositeType;
2150  //**********************************************************************************************
2151 
2152  //**Compilation flags***************************************************************************
2154  enum { vectorizable = 0 };
2155  //**********************************************************************************************
2156 
2157  //**Constructor*********************************************************************************
2164  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
2165  : vector_( vector ) // The dense vector/sparse vector cross product expression
2166  , offset_( index ) // The offset of the subvector within the cross product expression
2167  , size_ ( n ) // The size of the subvector
2168  {}
2169  //**********************************************************************************************
2170 
2171  //**Subscript operator**************************************************************************
2177  inline ReturnType operator[]( size_t index ) const {
2178  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2179  return vector_[offset_+index];
2180  }
2181  //**********************************************************************************************
2182 
2183  //**Size function*******************************************************************************
2188  inline size_t size() const {
2189  return size_;
2190  }
2191  //**********************************************************************************************
2192 
2193  //**********************************************************************************************
2199  template< typename T >
2200  inline bool canAlias( const T* alias ) const {
2201  return vector_.canAlias( alias );
2202  }
2203  //**********************************************************************************************
2204 
2205  //**********************************************************************************************
2211  template< typename T >
2212  inline bool isAliased( const T* alias ) const {
2213  return vector_.isAliased( alias );
2214  }
2215  //**********************************************************************************************
2216 
2217  private:
2218  //**Member variables****************************************************************************
2221  CPE vector_;
2222  const size_t offset_;
2223  const size_t size_;
2224 
2225  //**********************************************************************************************
2226 
2227  //**Friend declarations*************************************************************************
2228  template< typename VT, bool TF >
2229  friend DenseSubvector<VT,TF> subvector( const DenseSubvector<VT,TF>& dv, size_t index, size_t size );
2230  //**********************************************************************************************
2231 };
2233 //*************************************************************************************************
2234 
2235 
2236 
2237 
2238 
2239 
2240 
2241 
2242 //=================================================================================================
2243 //
2244 // CLASS TEMPLATE SPECIALIZATION FOR SVECDVECCROSSEXPR
2245 //
2246 //=================================================================================================
2247 
2248 //*************************************************************************************************
2256 template< typename VT1 // Type of the left-hand side sparse vector
2257  , typename VT2 > // Type of the right-hand side dense vector
2258 class DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, false >
2259  : public DenseVector< DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, false >, false >
2260  , private View
2261 {
2262  private:
2263  //**Type definitions****************************************************************************
2264  typedef SVecDVecCrossExpr<VT1,VT2> CPE;
2265  typedef typename CPE::ResultType RT;
2266  //**********************************************************************************************
2267 
2268  public:
2269  //**Type definitions****************************************************************************
2270  typedef DenseSubvector<CPE,false> This;
2271  typedef typename SubvectorTrait<RT>::Type ResultType;
2272  typedef typename ResultType::TransposeType TransposeType;
2273  typedef typename CPE::ElementType ElementType;
2274  typedef typename CPE::ReturnType ReturnType;
2275  typedef const ResultType CompositeType;
2276  //**********************************************************************************************
2277 
2278  //**Compilation flags***************************************************************************
2280  enum { vectorizable = 0 };
2281  //**********************************************************************************************
2282 
2283  //**Constructor*********************************************************************************
2290  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
2291  : vector_( vector ) // The sparse vector/dense vector cross product expression
2292  , offset_( index ) // The offset of the subvector within the cross product expression
2293  , size_ ( n ) // The size of the subvector
2294  {}
2295  //**********************************************************************************************
2296 
2297  //**Subscript operator**************************************************************************
2303  inline ReturnType operator[]( size_t index ) const {
2304  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2305  return vector_[offset_+index];
2306  }
2307  //**********************************************************************************************
2308 
2309  //**Size function*******************************************************************************
2314  inline size_t size() const {
2315  return size_;
2316  }
2317  //**********************************************************************************************
2318 
2319  //**********************************************************************************************
2325  template< typename T >
2326  inline bool canAlias( const T* alias ) const {
2327  return vector_.canAlias( alias );
2328  }
2329  //**********************************************************************************************
2330 
2331  //**********************************************************************************************
2337  template< typename T >
2338  inline bool isAliased( const T* alias ) const {
2339  return vector_.isAliased( alias );
2340  }
2341  //**********************************************************************************************
2342 
2343  private:
2344  //**Member variables****************************************************************************
2347  CPE vector_;
2348  const size_t offset_;
2349  const size_t size_;
2350 
2351  //**********************************************************************************************
2352 
2353  //**Friend declarations*************************************************************************
2354  template< typename VT, bool TF >
2355  friend DenseSubvector<VT,TF> subvector( const DenseSubvector<VT,TF>& dv, size_t index, size_t size );
2356  //**********************************************************************************************
2357 };
2359 //*************************************************************************************************
2360 
2361 
2362 
2363 
2364 
2365 
2366 
2367 
2368 //=================================================================================================
2369 //
2370 // CLASS TEMPLATE SPECIALIZATION FOR SVECSVECCROSSEXPR
2371 //
2372 //=================================================================================================
2373 
2374 //*************************************************************************************************
2382 template< typename VT1 // Type of the left-hand side sparse vector
2383  , typename VT2 > // Type of the right-hand side sparse vector
2384 class DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, false >
2385  : public DenseVector< DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, false >, false >
2386  , private View
2387 {
2388  private:
2389  //**Type definitions****************************************************************************
2390  typedef SVecSVecCrossExpr<VT1,VT2> CPE;
2391  typedef typename CPE::ResultType RT;
2392  //**********************************************************************************************
2393 
2394  public:
2395  //**Type definitions****************************************************************************
2396  typedef DenseSubvector<CPE,false> This;
2397  typedef typename SubvectorTrait<RT>::Type ResultType;
2398  typedef typename ResultType::TransposeType TransposeType;
2399  typedef typename CPE::ElementType ElementType;
2400  typedef typename CPE::ReturnType ReturnType;
2401  typedef const ResultType CompositeType;
2402  //**********************************************************************************************
2403 
2404  //**Compilation flags***************************************************************************
2406  enum { vectorizable = 0 };
2407  //**********************************************************************************************
2408 
2409  //**Constructor*********************************************************************************
2416  explicit inline DenseSubvector( const CPE& vector, size_t index, size_t n )
2417  : vector_( vector ) // The sparse vector/sparse vector cross product expression
2418  , offset_( index ) // The offset of the subvector within the cross product expression
2419  , size_ ( n ) // The size of the subvector
2420  {}
2421  //**********************************************************************************************
2422 
2423  //**Subscript operator**************************************************************************
2429  inline ReturnType operator[]( size_t index ) const {
2430  BLAZE_INTERNAL_ASSERT( index < size_, "Invalid vector access index" );
2431  return vector_[offset_+index];
2432  }
2433  //**********************************************************************************************
2434 
2435  //**Size function*******************************************************************************
2440  inline size_t size() const {
2441  return size_;
2442  }
2443  //**********************************************************************************************
2444 
2445  //**********************************************************************************************
2451  template< typename T >
2452  inline bool canAlias( const T* alias ) const {
2453  return vector_.canAlias( alias );
2454  }
2455  //**********************************************************************************************
2456 
2457  //**********************************************************************************************
2463  template< typename T >
2464  inline bool isAliased( const T* alias ) const {
2465  return vector_.isAliased( alias );
2466  }
2467  //**********************************************************************************************
2468 
2469  private:
2470  //**Member variables****************************************************************************
2473  CPE vector_;
2474  const size_t offset_;
2475  const size_t size_;
2476 
2477  //**********************************************************************************************
2478 
2479  //**Friend declarations*************************************************************************
2480  template< typename VT, bool TF >
2481  friend DenseSubvector<VT,TF> subvector( const DenseSubvector<VT,TF>& dv, size_t index, size_t size );
2482  //**********************************************************************************************
2483 };
2485 //*************************************************************************************************
2486 
2487 
2488 
2489 
2490 
2491 
2492 
2493 
2494 //=================================================================================================
2495 //
2496 // DENSESUBVECTOR OPERATORS
2497 //
2498 //=================================================================================================
2499 
2500 //*************************************************************************************************
2503 template< typename VT, bool TF >
2504 inline void reset( DenseSubvector<VT,TF>& dv );
2505 
2506 template< typename VT, bool TF >
2507 inline void clear( DenseSubvector<VT,TF>& dv );
2508 
2509 template< typename VT, bool TF >
2510 inline bool isDefault( const DenseSubvector<VT,TF>& dv );
2512 //*************************************************************************************************
2513 
2514 
2515 //*************************************************************************************************
2522 template< typename VT // Type of the dense vector
2523  , bool TF > // Transpose flag
2524 inline void reset( DenseSubvector<VT,TF>& dv )
2525 {
2526  dv.reset();
2527 }
2528 //*************************************************************************************************
2529 
2530 
2531 //*************************************************************************************************
2538 template< typename VT // Type of the dense vector
2539  , bool TF > // Transpose flag
2540 inline void clear( DenseSubvector<VT,TF>& dv )
2541 {
2542  dv.reset();
2543 }
2544 //*************************************************************************************************
2545 
2546 
2547 //*************************************************************************************************
2566 template< typename VT // Type of the dense vector
2567  , bool TF > // Transpose flag
2568 inline bool isDefault( const DenseSubvector<VT,TF>& dv )
2569 {
2570  for( size_t i=0UL; i<dv.size(); ++i )
2571  if( !isDefault( dv[i] ) ) return false;
2572  return true;
2573 }
2574 //*************************************************************************************************
2575 
2576 
2577 
2578 
2579 //=================================================================================================
2580 //
2581 // GLOBAL FUNCTION
2582 //
2583 //=================================================================================================
2584 
2585 //*************************************************************************************************
2613 template< typename VT // Type of the dense vector
2614  , bool TF > // Transpose flag
2615 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >, DenseSubvector<VT> >::Type
2616  subvector( DenseVector<VT,TF>& dv, size_t index, size_t size )
2617 {
2619 
2620  return DenseSubvector<VT>( ~dv, index, size );
2621 }
2622 //*************************************************************************************************
2623 
2624 
2625 //*************************************************************************************************
2653 template< typename VT // Type of the dense vector
2654  , bool TF > // Transpose flag
2655 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >, DenseSubvector<const VT> >::Type
2656  subvector( const DenseVector<VT,TF>& dv, size_t index, size_t size )
2657 {
2659 
2660  return DenseSubvector<const VT>( ~dv, index, size );
2661 }
2662 //*************************************************************************************************
2663 
2664 
2665 
2666 
2667 //=================================================================================================
2668 //
2669 // GLOBAL RESTRUCTURING OPERATORS
2670 //
2671 //=================================================================================================
2672 
2673 //*************************************************************************************************
2686 template< typename VT // Type of the dense subvector
2687  , bool TF > // Transpose flag
2688 inline DenseSubvector<VT,TF>
2689  subvector( const DenseSubvector<VT,TF>& dv, size_t index, size_t size )
2690 {
2692 
2693  return DenseSubvector<VT,TF>( dv.vector_, dv.offset_ + index, size );
2694 }
2696 //*************************************************************************************************
2697 
2698 
2699 //*************************************************************************************************
2712 template< typename VT // Type of the dense vector
2713  , bool TF > // Transpose flag
2714 inline typename EnableIf< IsCrossExpr<VT>, DenseSubvector<VT> >::Type
2715  subvector( const DenseVector<VT,TF>& dv, size_t index, size_t size )
2716 {
2718 
2719  return DenseSubvector<VT>( ~dv, index, size );
2720 }
2722 //*************************************************************************************************
2723 
2724 
2725 
2726 
2727 //=================================================================================================
2728 //
2729 // SUBVECTORTRAIT SPECIALIZATIONS
2730 //
2731 //=================================================================================================
2732 
2733 //*************************************************************************************************
2735 template< typename VT, bool TF >
2736 struct SubvectorTrait< DenseSubvector<VT,TF> >
2737 {
2738  typedef typename SubvectorTrait< typename DenseSubvector<VT,TF>::ResultType >::Type Type;
2739 };
2741 //*************************************************************************************************
2742 
2743 
2744 
2745 
2746 //=================================================================================================
2747 //
2748 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
2749 //
2750 //=================================================================================================
2751 
2752 //*************************************************************************************************
2754 template< typename VT, bool TF >
2755 struct SubvectorExprTrait< DenseSubvector<VT,TF> >
2756 {
2757  typedef DenseSubvector<VT,TF> Type;
2758 };
2760 //*************************************************************************************************
2761 
2762 
2763 //*************************************************************************************************
2765 template< typename VT, bool TF >
2766 struct SubvectorExprTrait< const DenseSubvector<VT,TF> >
2767 {
2768  typedef DenseSubvector<VT,TF> Type;
2769 };
2771 //*************************************************************************************************
2772 
2773 
2774 //*************************************************************************************************
2776 template< typename VT, bool TF >
2777 struct SubvectorExprTrait< volatile DenseSubvector<VT,TF> >
2778 {
2779  typedef DenseSubvector<VT,TF> Type;
2780 };
2782 //*************************************************************************************************
2783 
2784 
2785 //*************************************************************************************************
2787 template< typename VT, bool TF >
2788 struct SubvectorExprTrait< const volatile DenseSubvector<VT,TF> >
2789 {
2790  typedef DenseSubvector<VT,TF> Type;
2791 };
2793 //*************************************************************************************************
2794 
2795 
2796 //*************************************************************************************************
2798 template< typename VT1, typename VT2 >
2799 struct SubvectorExprTrait< DVecDVecCrossExpr<VT1,VT2> >
2800 {
2801  public:
2802  //**********************************************************************************************
2803  typedef DenseSubvector< DVecDVecCrossExpr<VT1,VT2>, false > Type;
2804  //**********************************************************************************************
2805 };
2807 //*************************************************************************************************
2808 
2809 
2810 //*************************************************************************************************
2812 template< typename VT1, typename VT2 >
2813 struct SubvectorExprTrait< DVecSVecCrossExpr<VT1,VT2> >
2814 {
2815  public:
2816  //**********************************************************************************************
2817  typedef DenseSubvector< DVecSVecCrossExpr<VT1,VT2>, false > Type;
2818  //**********************************************************************************************
2819 };
2821 //*************************************************************************************************
2822 
2823 
2824 //*************************************************************************************************
2826 template< typename VT1, typename VT2 >
2827 struct SubvectorExprTrait< SVecDVecCrossExpr<VT1,VT2> >
2828 {
2829  public:
2830  //**********************************************************************************************
2831  typedef DenseSubvector< SVecDVecCrossExpr<VT1,VT2>, false > Type;
2832  //**********************************************************************************************
2833 };
2835 //*************************************************************************************************
2836 
2837 
2838 //*************************************************************************************************
2840 template< typename VT1, typename VT2 >
2841 struct SubvectorExprTrait< SVecSVecCrossExpr<VT1,VT2> >
2842 {
2843  public:
2844  //**********************************************************************************************
2845  typedef DenseSubvector< SVecSVecCrossExpr<VT1,VT2>, false > Type;
2846  //**********************************************************************************************
2847 };
2849 //*************************************************************************************************
2850 
2851 } // namespace blaze
2852 
2853 #endif
ValueType value_type
Type of the underlying elements.
Definition: DenseSubvector.h:361
Constraint on the data type.
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubmatrix.h:2797
Constraint on the data type.
DenseSubvector(VT &vector, size_t index, size_t n)
The constructor for DenseSubvector.
Definition: DenseSubvector.h:868
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
SelectType< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a constant subvector value.
Definition: DenseSubvector.h:333
SelectType< useConst, ConstIterator, SubvectorIterator< typename VT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseSubvector.h:628
Header file for the View base class.
Header file for the IsCrossExpr type trait class.
bool operator<(const SubvectorIterator &rhs) const
Less-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:528
void reset()
Reset to the default initial values.
Definition: DenseSubvector.h:1380
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
VT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseSubvector.h:320
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
#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
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
SubvectorIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DenseSubvector.h:401
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
Header file for the IsRowVector type trait.
void storeu(float *address, const sse_float_t &value)
Unaligned store of a vector of &#39;float&#39; values.
Definition: Storeu.h:234
Header file for the DenseVector base class.
Header file for the IsTransExpr type trait class.
const size_t offset_
The offset of the subvector within the dense vector.
Definition: DenseSubvector.h:806
Expression object for dense vector-dense vector cross products.The DVecDVecCrossExpr class represents...
Definition: DVecDVecCrossExpr.h:81
Header file for the Computation base class.
const bool aligned_
Memory alignment flag.
Definition: DenseSubvector.h:814
bool canAlias(const Other *alias) const
Returns whether the dense subvector can alias with the given address alias.
Definition: DenseSubvector.h:1431
const size_t final_
The final index for unaligned intrinsic operations.
Definition: DenseSubmatrix.h:2798
#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
Header file for the RequiresEvaluation type trait.
Iterator begin()
Returns an iterator to the first element of the subvector.
Definition: DenseSubvector.h:966
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
VT::ConstReference ConstReference
Reference to a constant subvector value.
Definition: DenseSubvector.h:324
const SubvectorIterator operator++(int)
Post-increment operator.
Definition: DenseSubvector.h:423
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:122
ConstIterator cend() const
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1051
VT::ElementType ElementType
Type of the subvector elements.
Definition: DenseSubvector.h:318
const SubvectorIterator operator--(int)
Post-decrement operator.
Definition: DenseSubvector.h:444
bool operator<=(const SubvectorIterator &rhs) const
Less-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:550
std::iterator_traits< IteratorType >::iterator_category IteratorCategory
The iterator category.
Definition: DenseSubvector.h:345
bool operator==(const SubvectorIterator &rhs) const
Equality comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:506
IntrinsicType load() const
Aligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:469
Pointer data()
Low-level data access to the subvector elements.
Definition: DenseSubvector.h:934
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
std::iterator_traits< IteratorType >::value_type ValueType
Type of the underlying elements.
Definition: DenseSubvector.h:348
DifferenceType operator-(const SubvectorIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DenseSubvector.h:572
Header file for nested template disabiguation.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
SubvectorIterator & operator--()
Pre-decrement operator.
Definition: DenseSubvector.h:433
Header file for the Or class template.
std::iterator_traits< IteratorType >::pointer PointerType
Pointer return type.
Definition: DenseSubvector.h:351
friend const SubvectorIterator operator-(const SubvectorIterator &it, size_t dec)
Subtraction between a SubvectorIterator and an integral value.
Definition: DenseSubvector.h:608
const ElementType * ConstPointer
Pointer to a constant subvector value.
Definition: DenseSubvector.h:330
std::iterator_traits< IteratorType >::reference ReferenceType
Reference return type.
Definition: DenseSubvector.h:354
Header file for the subvector trait.
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:179
Iterator end()
Returns an iterator just past the last element of the subvector.
Definition: DenseSubvector.h:1017
friend const SubvectorIterator operator+(size_t inc, const SubvectorIterator &it)
Addition between an integral value and a SubvectorIterator.
Definition: DenseSubvector.h:596
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
Constraint on the data type.
SubvectorIterator & operator++()
Pre-increment operator.
Definition: DenseSubvector.h:412
bool aligned_
Memory alignment flag.
Definition: DenseSubvector.h:618
Constraint on the data type.
SelectType< useConst, ConstReference, typename VT::Reference >::Type Reference
Reference to a non-constant subvector value.
Definition: DenseSubvector.h:327
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:79
Constraint on the data type.
size_t nonZeros() const
Returns the number of non-zero elements in the subvector.
Definition: DenseSubvector.h:1358
bool operator!=(const SubvectorIterator &rhs) const
Inequality comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:517
Reference operator[](size_t index)
Subscript operator for the direct access to the subvector elements.
Definition: DenseSubvector.h:900
SubvectorIterator(IteratorType iterator, IteratorType final, size_t rest, bool aligned)
Constructor for the SubvectorIterator class.
Definition: DenseSubvector.h:375
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
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:269
Operand vector_
The dense vector containing the subvector.
Definition: DenseSubvector.h:805
Constraint on the data type.
Header file for the SelectType class template.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2377
size_t rest_
The number of remaining elements beyond the final iterator.
Definition: DenseSubvector.h:617
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
size_t capacity() const
Returns the maximum capacity of the dense subvector.
Definition: DenseSubvector.h:1341
bool operator>=(const SubvectorIterator &rhs) const
Greater-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:561
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:1497
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
Header file for the CrossExpr base class.
Header file for the IsNumeric type trait.
ConstIterator cbegin() const
Returns an iterator to the first element of the subvector.
Definition: DenseSubvector.h:1000
ReferenceType reference
Reference return type.
Definition: DenseSubvector.h:363
IT::Type IntrinsicType
Intrinsic type of the subvector elements.
Definition: DenseSubvector.h:319
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2374
Header file for the IsConst type trait.
const size_t size_
The size of the subvector.
Definition: DenseSubvector.h:807
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:648
const size_t final_
The final index for unaligned intrinsic operations.
Definition: DenseSubvector.h:809
IteratorType iterator_
Iterator to the current subvector element.
Definition: DenseSubvector.h:615
Header file for run time assertion macros.
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:209
View on a specific subvector of a dense vector.The DenseSubvector template represents a view on a spe...
Definition: DenseSubvector.h:290
DifferenceType difference_type
Difference between two iterators.
Definition: DenseSubvector.h:364
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
bool isAliased(const Other *alias) const
Returns whether the dense subvector is aliased with the given address alias.
Definition: DenseSubvector.h:1451
Header file for the reset shim.
IntrinsicTrait< typename VT::ElementType > IT
Intrinsic trait for the vector element type.
Definition: DenseSubvector.h:299
Header file for the cache size of the target architecture.
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2378
Header file for the isDefault shim.
SubvectorTrait< VT >::Type ResultType
Result type for expression template evaluations.
Definition: DenseSubvector.h:316
size_t size() const
Returns the current size/dimension of the dense subvector.
Definition: DenseSubvector.h:1327
#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
SelectType< IsExpression< VT >::value, VT, VT & >::Type Operand
Composite data type of the dense vector expression.
Definition: DenseSubvector.h:296
IntrinsicType loadu() const
Unaligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:484
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
Header file for all intrinsic functionality.
DenseSubvector< VT, TF > This
Type of this DenseSubvector instance.
Definition: DenseSubvector.h:315
friend const SubvectorIterator operator+(const SubvectorIterator &it, size_t inc)
Addition between a SubvectorIterator and an integral value.
Definition: DenseSubvector.h:584
#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
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseSubvector.h:317
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1533
const DenseSubvector & CompositeType
Data type for composite expression templates.
Definition: DenseSubvector.h:321
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:147
Base class for all views.The View class serves as a tag for all views (subvectors, submatrices, rows, columns, ...). All classes that represent a view and that are used within the expression template environment of the Blaze library have to derive from this class in order to qualify as a view. Only in case a class is derived from the View base class, the IsView type trait recognizes the class as valid view.
Definition: View.h:64
Header file for the IsComputation type trait class.
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:247
const bool aligned_
Memory alignment flag.
Definition: DenseSubmatrix.h:2803
PointerType pointer
Pointer return type.
Definition: DenseSubvector.h:362
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
IteratorCategory iterator_category
The iterator category.
Definition: DenseSubvector.h:360
Header file for basic type definitions.
Header file for the SubvectorExprTrait class template.
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1590
Iterator over the elements of the sparse subvector.
Definition: DenseSubvector.h:340
void storeu(size_t index, const IntrinsicType &value)
Unaligned store of an intrinsic element of the subvector.
Definition: DenseSubvector.h:1556
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
SubvectorIterator< typename VT::ConstIterator > ConstIterator
Iterator over constant elements.
Definition: DenseSubvector.h:625
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
Greater-than comparison between two SubvectorIterator objects.
Definition: DenseSubvector.h:539
SubvectorIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DenseSubvector.h:389
DenseSubvector & operator=(const ElementType &rhs)
Homogenous assignment to all subvector elements.
Definition: DenseSubvector.h:1075
#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
std::iterator_traits< IteratorType >::difference_type DifferenceType
Difference between two iterators.
Definition: DenseSubvector.h:357
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the dense subvector.
Definition: DenseSubvector.h:1474
#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
DisableIf< Or< IsComputation< VT >, IsTransExpr< VT > >, DenseSubvector< VT > >::Type subvector(DenseVector< VT, TF > &dv, size_t index, size_t size)
Creating a view on a specific subvector of the given dense vector.
Definition: DenseSubvector.h:2616
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubvector.h:808
IteratorType final_
The final iterator for intrinsic operations.
Definition: DenseSubvector.h:616
ReferenceType operator*() const
Direct access to the element at the current iterator position.
Definition: DenseSubvector.h:454
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.