All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseSubvector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SPARSESUBVECTOR_H_
36 #define _BLAZE_MATH_VIEWS_SPARSESUBVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <stdexcept>
66 #include <blaze/util/Assert.h>
67 #include <blaze/util/DisableIf.h>
68 #include <blaze/util/EnableIf.h>
70 #include <blaze/util/mpl/If.h>
71 #include <blaze/util/mpl/Or.h>
72 #include <blaze/util/SelectType.h>
73 #include <blaze/util/Types.h>
77 
78 
79 namespace blaze {
80 
81 //=================================================================================================
82 //
83 // CLASS DEFINITION
84 //
85 //=================================================================================================
86 
87 //*************************************************************************************************
319 template< typename VT // Type of the sparse vector
320  , bool TF = IsRowVector<VT>::value > // Transpose flag
321 class SparseSubvector : public SparseVector< SparseSubvector<VT,TF>, TF >
322  , private View
323 {
324  private:
325  //**Type definitions****************************************************************************
327  typedef typename SelectType< IsExpression<VT>::value, VT, VT& >::Type Operand;
328  //**********************************************************************************************
329 
330  //**********************************************************************************************
332 
338  enum { useConst = IsConst<VT>::value };
339  //**********************************************************************************************
340 
341  public:
342  //**Type definitions****************************************************************************
346  typedef typename VT::ElementType ElementType;
347  typedef typename VT::ReturnType ReturnType;
349 
352 
355  //**********************************************************************************************
356 
357  //**SubvectorElement class definition***********************************************************
360  template< typename VectorType // Type of the sparse vector
361  , typename IteratorType > // Type of the sparse vector iterator
363  {
364  private:
365  //*******************************************************************************************
367 
372  enum { returnConst = IsConst<VectorType>::value };
373  //*******************************************************************************************
374 
375  public:
376  //**Type definitions*************************************************************************
379  //*******************************************************************************************
380 
381  //**Constructor******************************************************************************
387  inline SubvectorElement( IteratorType pos, size_t offset )
388  : pos_ ( pos ) // Iterator to the current position within the sparse subvector
389  , offset_( offset ) // Offset within the according sparse vector
390  {}
391  //*******************************************************************************************
392 
393  //**Assignment operator**********************************************************************
399  template< typename T > inline SubvectorElement& operator=( const T& v ) {
400  *pos_ = v;
401  return *this;
402  }
403  //*******************************************************************************************
404 
405  //**Addition assignment operator*************************************************************
411  template< typename T > inline SubvectorElement& operator+=( const T& v ) {
412  *pos_ += v;
413  return *this;
414  }
415  //*******************************************************************************************
416 
417  //**Subtraction assignment operator**********************************************************
423  template< typename T > inline SubvectorElement& operator-=( const T& v ) {
424  *pos_ -= v;
425  return *this;
426  }
427  //*******************************************************************************************
428 
429  //**Multiplication assignment operator*******************************************************
435  template< typename T > inline SubvectorElement& operator*=( const T& v ) {
436  *pos_ *= v;
437  return *this;
438  }
439  //*******************************************************************************************
440 
441  //**Division assignment operator*************************************************************
447  template< typename T > inline SubvectorElement& operator/=( const T& v ) {
448  *pos_ /= v;
449  return *this;
450  }
451  //*******************************************************************************************
452 
453  //**Element access operator******************************************************************
458  inline const SubvectorElement* operator->() const {
459  return this;
460  }
461  //*******************************************************************************************
462 
463  //**Value function***************************************************************************
468  inline ReferenceType value() const {
469  return pos_->value();
470  }
471  //*******************************************************************************************
472 
473  //**Index function***************************************************************************
478  inline size_t index() const {
479  return pos_->index() - offset_;
480  }
481  //*******************************************************************************************
482 
483  private:
484  //**Member variables*************************************************************************
485  IteratorType pos_;
486  size_t offset_;
487  //*******************************************************************************************
488  };
489  //**********************************************************************************************
490 
491  //**SubvectorIterator class definition**********************************************************
494  template< typename VectorType // Type of the sparse vector
495  , typename IteratorType > // Type of the sparse vector iterator
497  {
498  public:
499  //**Type definitions*************************************************************************
500  typedef std::forward_iterator_tag IteratorCategory;
505 
506  // STL iterator requirements
512  //*******************************************************************************************
513 
514  //**Default constructor**********************************************************************
518  : pos_ () // Iterator to the current sparse element
519  , offset_() // The offset of the subvector within the sparse vector
520  {}
521  //*******************************************************************************************
522 
523  //**Constructor******************************************************************************
529  inline SubvectorIterator( IteratorType pos, size_t offset )
530  : pos_ ( pos ) // Iterator to the current sparse element
531  , offset_( offset ) // The offset of the subvector within the sparse vector
532  {}
533  //*******************************************************************************************
534 
535  //**Constructor******************************************************************************
540  template< typename VectorType2, typename IteratorType2 >
542  : pos_ ( it.pos_ ) // Iterator to the current sparse element.
543  , offset_( it.offset_ ) // The offset of the subvector within the sparse vector
544  {}
545  //*******************************************************************************************
546 
547  //**Prefix increment operator****************************************************************
553  ++pos_;
554  return *this;
555  }
556  //*******************************************************************************************
557 
558  //**Postfix increment operator***************************************************************
563  inline const SubvectorIterator operator++( int ) {
564  const SubvectorIterator tmp( *this );
565  ++(*this);
566  return tmp;
567  }
568  //*******************************************************************************************
569 
570  //**Element access operator******************************************************************
575  inline ReferenceType operator*() const {
576  return ReferenceType( pos_, offset_ );
577  }
578  //*******************************************************************************************
579 
580  //**Element access operator******************************************************************
585  inline PointerType operator->() const {
586  return PointerType( pos_, offset_ );
587  }
588  //*******************************************************************************************
589 
590  //**Equality operator************************************************************************
596  template< typename VectorType2, typename IteratorType2 >
598  return pos_ == rhs.pos_;
599  }
600  //*******************************************************************************************
601 
602  //**Inequality operator**********************************************************************
608  template< typename VectorType2, typename IteratorType2 >
610  return !( *this == rhs );
611  }
612  //*******************************************************************************************
613 
614  //**Subtraction operator*********************************************************************
620  inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
621  return pos_ - rhs.pos_;
622  }
623  //*******************************************************************************************
624 
625  private:
626  //**Member variables*************************************************************************
627  IteratorType pos_;
628  size_t offset_;
629  //*******************************************************************************************
630 
631  //**Friend declarations**********************************************************************
633  template< typename VectorType2, typename IteratorType2 > friend class SubvectorIterator;
634  template< typename VT2, bool TF2 > friend class SparseSubvector;
636  //*******************************************************************************************
637  };
638  //**********************************************************************************************
639 
640  //**Type definitions****************************************************************************
643 
646  //**********************************************************************************************
647 
648  //**Constructors********************************************************************************
651  explicit inline SparseSubvector( VT& vector, size_t index, size_t n );
652  // No explicitly declared copy constructor.
654  //**********************************************************************************************
655 
656  //**Destructor**********************************************************************************
657  // No explicitly declared destructor.
658  //**********************************************************************************************
659 
660  //**Data access functions***********************************************************************
663  inline Reference operator[]( size_t index );
664  inline ConstReference operator[]( size_t index ) const;
665  inline Iterator begin ();
666  inline ConstIterator begin () const;
667  inline ConstIterator cbegin() const;
668  inline Iterator end ();
669  inline ConstIterator end () const;
670  inline ConstIterator cend () const;
672  //**********************************************************************************************
673 
674  //**Assignment operators************************************************************************
677  inline SparseSubvector& operator= ( const SparseSubvector& rhs );
678  template< typename VT2 > inline SparseSubvector& operator= ( const DenseVector<VT2,TF>& rhs );
679  template< typename VT2 > inline SparseSubvector& operator= ( const SparseVector<VT2,TF>& rhs );
680  template< typename VT2 > inline SparseSubvector& operator+=( const Vector<VT2,TF>& rhs );
681  template< typename VT2 > inline SparseSubvector& operator-=( const Vector<VT2,TF>& rhs );
682  template< typename VT2 > inline SparseSubvector& operator*=( const Vector<VT2,TF>& rhs );
683 
684  template< typename Other >
685  inline typename EnableIf< IsNumeric<Other>, SparseSubvector >::Type&
686  operator*=( Other rhs );
687 
688  template< typename Other >
689  inline typename EnableIf< IsNumeric<Other>, SparseSubvector >::Type&
690  operator/=( Other rhs );
692  //**********************************************************************************************
693 
694  //**Utility functions***************************************************************************
697  inline size_t size() const;
698  inline size_t capacity() const;
699  inline size_t nonZeros() const;
700  inline void reset();
701  inline Iterator insert ( size_t index, const ElementType& value );
702  inline void erase ( size_t index );
703  inline Iterator erase ( Iterator pos );
704  inline Iterator erase ( Iterator first, Iterator last );
705  inline void reserve( size_t n );
706  template< typename Other > inline SparseSubvector& scale ( Other scalar );
708  //**********************************************************************************************
709 
710  //**Lookup functions****************************************************************************
713  inline Iterator find ( size_t index );
714  inline ConstIterator find ( size_t index ) const;
715  inline Iterator lowerBound( size_t index );
716  inline ConstIterator lowerBound( size_t index ) const;
717  inline Iterator upperBound( size_t index );
718  inline ConstIterator upperBound( size_t index ) const;
720  //**********************************************************************************************
721 
722  //**Low-level utility functions*****************************************************************
725  inline void append( size_t index, const ElementType& value, bool check=false );
727  //**********************************************************************************************
728 
729  //**Expression template evaluation functions****************************************************
732  template< typename Other > inline bool canAlias ( const Other* alias ) const;
733  template< typename Other > inline bool isAliased( const Other* alias ) const;
734  template< typename VT2 > inline void assign ( const DenseVector <VT2,TF>& rhs );
735  template< typename VT2 > inline void assign ( const SparseVector<VT2,TF>& rhs );
736  template< typename VT2 > inline void addAssign( const DenseVector <VT2,TF>& rhs );
737  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
738  template< typename VT2 > inline void subAssign( const DenseVector <VT2,TF>& rhs );
739  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
741  //**********************************************************************************************
742 
743  private:
744  //**Member variables****************************************************************************
748  const size_t offset_;
749  const size_t size_;
750 
751  //**********************************************************************************************
752 
753  //**Friend declarations*************************************************************************
755  template< typename VT2, bool TF2 >
756  friend SparseSubvector<VT2,TF2> subvector( const SparseSubvector<VT2,TF2>& sv, size_t index, size_t size );
758  //**********************************************************************************************
759 
760  //**Compile time checks*************************************************************************
767  //**********************************************************************************************
768 };
769 //*************************************************************************************************
770 
771 
772 
773 
774 //=================================================================================================
775 //
776 // CONSTRUCTOR
777 //
778 //=================================================================================================
779 
780 //*************************************************************************************************
792 template< typename VT // Type of the sparse vector
793  , bool TF > // Transpose flag
794 inline SparseSubvector<VT,TF>::SparseSubvector( VT& vector, size_t index, size_t n )
795  : vector_( vector ) // The sparse vector containing the subvector
796  , offset_( index ) // The offset of the subvector within the sparse vector
797  , size_ ( n ) // The size of the subvector
798 {
799  if( index + n > vector.size() )
800  throw std::invalid_argument( "Invalid subvector specification" );
801 }
802 //*************************************************************************************************
803 
804 
805 
806 
807 //=================================================================================================
808 //
809 // DATA ACCESS FUNCTIONS
810 //
811 //=================================================================================================
812 
813 //*************************************************************************************************
819 template< typename VT // Type of the sparse vector
820  , bool TF > // Transpose flag
821 inline typename SparseSubvector<VT,TF>::Reference
823 {
824  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
825  return vector_[offset_+index];
826 }
827 //*************************************************************************************************
828 
829 
830 //*************************************************************************************************
836 template< typename VT // Type of the sparse vector
837  , bool TF > // Transpose flag
840 {
841  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
842  return const_cast<const VT&>( vector_ )[offset_+index];
843 }
844 //*************************************************************************************************
845 
846 
847 //*************************************************************************************************
854 template< typename VT // Type of the sparse vector
855  , bool TF > // Transpose flag
857 {
858  if( offset_ == 0UL )
859  return Iterator( vector_.begin(), offset_ );
860  else
861  return Iterator( vector_.lowerBound( offset_ ), offset_ );
862 }
863 //*************************************************************************************************
864 
865 
866 //*************************************************************************************************
873 template< typename VT // Type of the sparse vector
874  , bool TF > // Transpose flag
876 {
877  if( offset_ == 0UL )
878  return ConstIterator( vector_.cbegin(), offset_ );
879  else
880  return ConstIterator( vector_.lowerBound( offset_ ), offset_ );
881 }
882 //*************************************************************************************************
883 
884 
885 //*************************************************************************************************
892 template< typename VT // Type of the sparse vector
893  , bool TF > // Transpose flag
895 {
896  if( offset_ == 0UL )
897  return ConstIterator( vector_.cbegin(), offset_ );
898  else
899  return ConstIterator( vector_.lowerBound( offset_ ), offset_ );
900 }
901 //*************************************************************************************************
902 
903 
904 //*************************************************************************************************
911 template< typename VT // Type of the sparse vector
912  , bool TF > // Transpose flag
914 {
915  if( offset_ + size_ == vector_.size() )
916  return Iterator( vector_.end(), offset_ );
917  else
918  return Iterator( vector_.lowerBound( offset_ + size_ ), offset_ );
919 }
920 //*************************************************************************************************
921 
922 
923 //*************************************************************************************************
930 template< typename VT // Type of the sparse vector
931  , bool TF > // Transpose flag
933 {
934  if( offset_ + size_ == vector_.size() )
935  return ConstIterator( vector_.cend(), offset_ );
936  else
937  return ConstIterator( vector_.lowerBound( offset_ + size_ ), offset_ );
938 }
939 //*************************************************************************************************
940 
941 
942 //*************************************************************************************************
949 template< typename VT // Type of the sparse vector
950  , bool TF > // Transpose flag
952 {
953  if( offset_ + size_ == vector_.size() )
954  return ConstIterator( vector_.cend(), offset_ );
955  else
956  return ConstIterator( vector_.lowerBound( offset_ + size_ ), offset_ );
957 }
958 //*************************************************************************************************
959 
960 
961 
962 
963 //=================================================================================================
964 //
965 // ASSIGNMENT OPERATORS
966 //
967 //=================================================================================================
968 
969 //*************************************************************************************************
979 template< typename VT // Type of the sparse vector
980  , bool TF > // Transpose flag
982 {
983  using blaze::assign;
984 
987 
988  if( this == &rhs || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
989  return *this;
990 
991  if( size() != rhs.size() )
992  throw std::invalid_argument( "Vector sizes do not match" );
993 
994  if( rhs.canAlias( &vector_ ) ) {
995  const ResultType tmp( rhs );
996  reset();
997  assign( *this, tmp );
998  }
999  else {
1000  reset();
1001  assign( *this, rhs );
1002  }
1003 
1004  return *this;
1005 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1019 template< typename VT // Type of the sparse vector
1020  , bool TF > // Transpose flag
1021 template< typename VT2 > // Type of the right-hand side dense vector
1023 {
1024  using blaze::assign;
1025 
1029 
1030  if( size() != (~rhs).size() )
1031  throw std::invalid_argument( "Vector sizes do not match" );
1032 
1033  if( RequiresEvaluation<VT2>::value || (~rhs).canAlias( &vector_ ) ) {
1034  const typename VT2::ResultType tmp( ~rhs );
1035  reset();
1036  assign( *this, tmp );
1037  }
1038  else {
1039  reset();
1040  assign( *this, ~rhs );
1041  }
1042 
1043  return *this;
1044 }
1045 //*************************************************************************************************
1046 
1047 
1048 //*************************************************************************************************
1058 template< typename VT // Type of the sparse vector
1059  , bool TF > // Transpose flag
1060 template< typename VT2 > // Type of the right-hand side sparse vector
1062 {
1063  using blaze::assign;
1064 
1068 
1069  if( size() != (~rhs).size() )
1070  throw std::invalid_argument( "Vector sizes do not match" );
1071 
1072  if( RequiresEvaluation<VT2>::value || (~rhs).canAlias( &vector_ ) ) {
1073  const typename VT2::ResultType tmp( ~rhs );
1074  reset();
1075  assign( *this, tmp );
1076  }
1077  else {
1078  reset();
1079  assign( *this, ~rhs );
1080  }
1081 
1082  return *this;
1083 }
1084 //*************************************************************************************************
1085 
1086 
1087 //*************************************************************************************************
1097 template< typename VT // Type of the sparse vector
1098  , bool TF > // Transpose flag
1099 template< typename VT2 > // Type of the right-hand side vector
1101 {
1102  using blaze::addAssign;
1103 
1104  if( size() != (~rhs).size() )
1105  throw std::invalid_argument( "Vector sizes do not match" );
1106 
1107  addAssign( *this, ~rhs );
1108 
1109  return *this;
1110 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1124 template< typename VT // Type of the sparse vector
1125  , bool TF > // Transpose flag
1126 template< typename VT2 > // Type of the right-hand side vector
1128 {
1129  using blaze::subAssign;
1130 
1131  if( size() != (~rhs).size() )
1132  throw std::invalid_argument( "Vector sizes do not match" );
1133 
1134  subAssign( *this, ~rhs );
1135 
1136  return *this;
1137 }
1138 //*************************************************************************************************
1139 
1140 
1141 //*************************************************************************************************
1152 template< typename VT // Type of the sparse vector
1153  , bool TF > // Transpose flag
1154 template< typename VT2 > // Type of the right-hand side vector
1156 {
1157  if( size() != (~rhs).size() )
1158  throw std::invalid_argument( "Vector sizes do not match" );
1159 
1160  typedef typename MultTrait<ResultType,typename VT2::ResultType>::Type MultType;
1161 
1165 
1166  const MultType tmp( *this * (~rhs) );
1167  reset();
1168  assign( tmp );
1169 
1170  return *this;
1171 }
1172 //*************************************************************************************************
1173 
1174 
1175 //*************************************************************************************************
1186 template< typename VT // Type of the sparse vector
1187  , bool TF > // Transpose flag
1188 template< typename Other > // Data type of the right-hand side scalar
1189 inline typename EnableIf< IsNumeric<Other>, SparseSubvector<VT,TF> >::Type&
1191 {
1192  const Iterator last( end() );
1193  for( Iterator element=begin(); element!=last; ++element )
1194  element->value() *= rhs;
1195  return *this;
1196 }
1197 //*************************************************************************************************
1198 
1199 
1200 //*************************************************************************************************
1212 template< typename VT // Type of the sparse vector
1213  , bool TF > // Transpose flag
1214 template< typename Other > // Data type of the right-hand side scalar
1215 inline typename EnableIf< IsNumeric<Other>, SparseSubvector<VT,TF> >::Type&
1217 {
1218  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1219 
1220  typedef typename DivTrait<ElementType,Other>::Type DT;
1221  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
1222 
1223  const Iterator last( end() );
1224 
1225  // Depending on the two involved data types, an integer division is applied or a
1226  // floating point division is selected.
1228  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1229  for( Iterator element=begin(); element!=last; ++element )
1230  element->value() *= tmp;
1231  }
1232  else {
1233  for( Iterator element=begin(); element!=last; ++element )
1234  element->value() /= rhs;
1235  }
1236 
1237  return *this;
1238 }
1239 //*************************************************************************************************
1240 
1241 
1242 
1243 
1244 //=================================================================================================
1245 //
1246 // UTILITY FUNCTIONS
1247 //
1248 //=================================================================================================
1249 
1250 //*************************************************************************************************
1255 template< typename VT // Type of the sparse vector
1256  , bool TF > // Transpose flag
1257 inline size_t SparseSubvector<VT,TF>::size() const
1258 {
1259  return size_;
1260 }
1261 //*************************************************************************************************
1262 
1263 
1264 //*************************************************************************************************
1269 template< typename VT // Type of the sparse vector
1270  , bool TF > // Transpose flag
1272 {
1273  return nonZeros() + vector_.capacity() - vector_.nonZeros();
1274 }
1275 //*************************************************************************************************
1276 
1277 
1278 //*************************************************************************************************
1285 template< typename VT // Type of the sparse vector
1286  , bool TF > // Transpose flag
1288 {
1289  return end() - begin();
1290 }
1291 //*************************************************************************************************
1292 
1293 
1294 //*************************************************************************************************
1299 template< typename VT // Type of the sparse vector
1300  , bool TF > // Transpose flag
1302 {
1303  vector_.erase( vector_.lowerBound( offset_ ), vector_.lowerBound( offset_ + size_ ) );
1304 }
1305 //*************************************************************************************************
1306 
1307 
1308 //*************************************************************************************************
1320 template< typename VT // Type of the sparse vector
1321  , bool TF > // Transpose flag
1322 inline typename SparseSubvector<VT,TF>::Iterator
1323  SparseSubvector<VT,TF>::insert( size_t index, const ElementType& value )
1324 {
1325  return Iterator( vector_.insert( offset_ + index, value ), offset_ );
1326 }
1327 //*************************************************************************************************
1328 
1329 
1330 //*************************************************************************************************
1338 template< typename VT // Type of the sparse vector
1339  , bool TF > // Transpose flag
1340 inline void SparseSubvector<VT,TF>::erase( size_t index )
1341 {
1342  vector_.erase( offset_ + index );
1343 }
1344 //*************************************************************************************************
1345 
1346 
1347 //*************************************************************************************************
1355 template< typename VT // Type of the sparse vector
1356  , bool TF > // Transpose flag
1358 {
1359  return Iterator( vector_.erase( pos.pos_ ), offset_ );
1360 }
1361 //*************************************************************************************************
1362 
1363 
1364 //*************************************************************************************************
1373 template< typename VT // Type of the sparse vector
1374  , bool TF > // Transpose flag
1376 {
1377  return Iterator( vector_.erase( first.pos_, last.pos_ ), offset_ );
1378 }
1379 //*************************************************************************************************
1380 
1381 
1382 //*************************************************************************************************
1391 template< typename VT // Type of the sparse vector
1392  , bool TF > // Transpose flag
1394 {
1395  const size_t current( capacity() );
1396 
1397  if( n > current ) {
1398  vector_.reserve( vector_.capacity() + n - current );
1399  }
1400 }
1401 //*************************************************************************************************
1402 
1403 
1404 //*************************************************************************************************
1410 template< typename VT // Type of the sparse vector
1411  , bool TF > // Transpose flag
1412 template< typename Other > // Data type of the scalar value
1414 {
1415  for( Iterator element=begin(); element!=end(); ++element )
1416  element->value() *= scalar;
1417  return *this;
1418 }
1419 //*************************************************************************************************
1420 
1421 
1422 
1423 
1424 //=================================================================================================
1425 //
1426 // LOOKUP FUNCTIONS
1427 //
1428 //=================================================================================================
1429 
1430 //*************************************************************************************************
1443 template< typename VT // Type of the sparse vector
1444  , bool TF > // Transpose flag
1446 {
1447  const typename VT::Iterator pos( vector_.find( offset_ + index ) );
1448 
1449  if( pos != vector_.end() )
1450  return Iterator( pos, offset_ );
1451  else
1452  return end();
1453 }
1454 //*************************************************************************************************
1455 
1456 
1457 //*************************************************************************************************
1470 template< typename VT // Type of the sparse vector
1471  , bool TF > // Transpose flag
1473 {
1474  const typename VT::ConstIterator pos( vector_.find( offset_ + index ) );
1475 
1476  if( pos != vector_.end() )
1477  return Iterator( pos, offset_ );
1478  else
1479  return end();
1480 }
1481 //*************************************************************************************************
1482 
1483 
1484 //*************************************************************************************************
1496 template< typename VT // Type of the sparse vector
1497  , bool TF > // Transpose flag
1499 {
1500  return Iterator( vector_.lowerBound( offset_ + index ), offset_ );
1501 }
1502 //*************************************************************************************************
1503 
1504 
1505 //*************************************************************************************************
1517 template< typename VT // Type of the sparse vector
1518  , bool TF > // Transpose flag
1520 {
1521  return ConstIterator( vector_.lowerBound( offset_ + index ), offset_ );
1522 }
1523 //*************************************************************************************************
1524 
1525 
1526 //*************************************************************************************************
1538 template< typename VT // Type of the sparse vector
1539  , bool TF > // Transpose flag
1541 {
1542  return Iterator( vector_.upperBound( offset_ + index ), offset_ );
1543 }
1544 //*************************************************************************************************
1545 
1546 
1547 //*************************************************************************************************
1559 template< typename VT // Type of the sparse vector
1560  , bool TF > // Transpose flag
1562 {
1563  return ConstIterator( vector_.upperBound( offset_ + index ), offset_ );
1564 }
1565 //*************************************************************************************************
1566 
1567 
1568 
1569 
1570 //=================================================================================================
1571 //
1572 // LOW-LEVEL UTILITY FUNCTIONS
1573 //
1574 //=================================================================================================
1575 
1576 //*************************************************************************************************
1600 template< typename VT // Type of the sparse vector
1601  , bool TF > // Transpose flag
1602 inline void SparseSubvector<VT,TF>::append( size_t index, const ElementType& value, bool check )
1603 {
1604  if( offset_ + size_ == vector_.size() )
1605  vector_.append( offset_ + index, value, check );
1606  else if( !check || !isDefault( value ) )
1607  vector_.insert( offset_ + index, value );
1608 }
1609 //*************************************************************************************************
1610 
1611 
1612 
1613 
1614 //=================================================================================================
1615 //
1616 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1617 //
1618 //=================================================================================================
1619 
1620 //*************************************************************************************************
1630 template< typename VT // Type of the sparse vector
1631  , bool TF > // Transpose flag
1632 template< typename Other > // Data type of the foreign expression
1633 inline bool SparseSubvector<VT,TF>::canAlias( const Other* alias ) const
1634 {
1635  return static_cast<const void*>( &vector_ ) == static_cast<const void*>( alias );
1636 }
1637 //*************************************************************************************************
1638 
1639 
1640 //*************************************************************************************************
1650 template< typename VT // Type of the sparse vector
1651  , bool TF > // Transpose flag
1652 template< typename Other > // Data type of the foreign expression
1653 inline bool SparseSubvector<VT,TF>::isAliased( const Other* alias ) const
1654 {
1655  return static_cast<const void*>( &vector_ ) == static_cast<const void*>( alias );
1656 }
1657 //*************************************************************************************************
1658 
1659 
1660 //*************************************************************************************************
1671 template< typename VT // Type of the sparse vector
1672  , bool TF > // Transpose flag
1673 template< typename VT2 > // Type of the right-hand side dense vector
1675 {
1676  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1677  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1678 
1679  reserve( (~rhs).size() );
1680 
1681  for( size_t i=0UL; i<size(); ++i ) {
1682  append( i, (~rhs)[i], true );
1683  }
1684 }
1685 //*************************************************************************************************
1686 
1687 
1688 //*************************************************************************************************
1699 template< typename VT // Type of the sparse vector
1700  , bool TF > // Transpose flag
1701 template< typename VT2 > // Type of the right-hand side sparse vector
1703 {
1704  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1705  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1706 
1707  reserve( (~rhs).nonZeros() );
1708 
1709  for( typename VT2::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1710  append( element->index(), element->value(), true );
1711  }
1712 }
1713 //*************************************************************************************************
1714 
1715 
1716 //*************************************************************************************************
1727 template< typename VT // Type of the sparse vector
1728  , bool TF > // Transpose flag
1729 template< typename VT2 > // Type of the right-hand side dense vector
1731 {
1732  typedef typename AddTrait<ResultType,typename VT2::ResultType>::Type AddType;
1733 
1737 
1738  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1739 
1740  const AddType tmp( *this + (~rhs) );
1741  reset();
1742  assign( tmp );
1743 }
1744 //*************************************************************************************************
1745 
1746 
1747 //*************************************************************************************************
1758 template< typename VT // Type of the sparse vector
1759  , bool TF > // Transpose flag
1760 template< typename VT2 > // Type of the right-hand side sparse vector
1762 {
1763  typedef typename AddTrait<ResultType,typename VT2::ResultType>::Type AddType;
1764 
1768 
1769  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1770 
1771  const AddType tmp( *this + (~rhs) );
1772  reset();
1773  assign( tmp );
1774 }
1775 //*************************************************************************************************
1776 
1777 
1778 //*************************************************************************************************
1789 template< typename VT // Type of the sparse vector
1790  , bool TF > // Transpose flag
1791 template< typename VT2 > // Type of the right-hand side dense vector
1793 {
1794  typedef typename SubTrait<ResultType,typename VT2::ResultType>::Type SubType;
1795 
1799 
1800  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1801 
1802  const SubType tmp( *this - (~rhs) );
1803  reset();
1804  assign( tmp );
1805 }
1806 //*************************************************************************************************
1807 
1808 
1809 //*************************************************************************************************
1820 template< typename VT // Type of the sparse vector
1821  , bool TF > // Transpose flag
1822 template< typename VT2 > // Type of the right-hand side sparse vector
1824 {
1825  typedef typename SubTrait<ResultType,typename VT2::ResultType>::Type SubType;
1826 
1830 
1831  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1832 
1833  const SubType tmp( *this - (~rhs) );
1834  reset();
1835  assign( tmp );
1836 }
1837 //*************************************************************************************************
1838 
1839 
1840 
1841 
1842 
1843 
1844 
1845 
1846 //=================================================================================================
1847 //
1848 // SPARSESUBVECTOR OPERATORS
1849 //
1850 //=================================================================================================
1851 
1852 //*************************************************************************************************
1855 template< typename VT, bool TF >
1856 inline void reset( SparseSubvector<VT,TF>& sv );
1857 
1858 template< typename VT, bool TF >
1859 inline void clear( SparseSubvector<VT,TF>& sv );
1860 
1861 template< typename VT, bool TF >
1862 inline bool isDefault( const SparseSubvector<VT,TF>& sv );
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1874 template< typename VT // Type of the sparse vector
1875  , bool TF > // Transpose flag
1876 inline void reset( SparseSubvector<VT,TF>& sv )
1877 {
1878  sv.reset();
1879 }
1880 //*************************************************************************************************
1881 
1882 
1883 //*************************************************************************************************
1892 template< typename VT // Type of the sparse vector
1893  , bool TF > // Transpose flag
1894 inline void clear( SparseSubvector<VT,TF>& sv )
1895 {
1896  sv.reset();
1897 }
1898 //*************************************************************************************************
1899 
1900 
1901 //*************************************************************************************************
1919 template< typename VT // Type of the sparse vector
1920  , bool TF > // Transpose flag
1921 inline bool isDefault( const SparseSubvector<VT,TF>& sv )
1922 {
1924 
1925  const ConstIterator end( sv.end() );
1926  for( ConstIterator element=sv.begin(); element!=end; ++element )
1927  if( !isDefault( element->value() ) ) return false;
1928  return true;
1929 }
1930 //*************************************************************************************************
1931 
1932 
1933 
1934 
1935 //=================================================================================================
1936 //
1937 // GLOBAL FUNCTION
1938 //
1939 //=================================================================================================
1940 
1941 //*************************************************************************************************
1969 template< typename VT // Type of the sparse vector
1970  , bool TF > // Transpose flag
1971 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >, SparseSubvector<VT> >::Type
1972  subvector( SparseVector<VT,TF>& sv, size_t index, size_t size )
1973 {
1975 
1976  return SparseSubvector<VT>( ~sv, index, size );
1977 }
1978 //*************************************************************************************************
1979 
1980 
1981 //*************************************************************************************************
2009 template< typename VT // Type of the sparse vector
2010  , bool TF > // Transpose flag
2011 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >, SparseSubvector<const VT> >::Type
2012  subvector( const SparseVector<VT,TF>& sv, size_t index, size_t size )
2013 {
2015 
2016  return SparseSubvector<const VT>( ~sv, index, size );
2017 }
2018 //*************************************************************************************************
2019 
2020 
2021 
2022 
2023 //=================================================================================================
2024 //
2025 // GLOBAL RESTRUCTURING OPERATORS
2026 //
2027 //=================================================================================================
2028 
2029 //*************************************************************************************************
2042 template< typename VT // Type of the sparse subvector
2043  , bool TF > // Transpose flag
2044 inline SparseSubvector<VT,TF>
2045  subvector( const SparseSubvector<VT,TF>& sv, size_t index, size_t size )
2046 {
2048 
2049  return SparseSubvector<VT,TF>( sv.vector_, sv.offset_ + index, size );
2050 }
2052 //*************************************************************************************************
2053 
2054 
2055 
2056 
2057 //=================================================================================================
2058 //
2059 // SUBVECTORTRAIT SPECIALIZATIONS
2060 //
2061 //=================================================================================================
2062 
2063 //*************************************************************************************************
2065 template< typename VT, bool TF >
2066 struct SubvectorTrait< SparseSubvector<VT,TF> >
2067 {
2069 };
2071 //*************************************************************************************************
2072 
2073 
2074 
2075 
2076 //=================================================================================================
2077 //
2078 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
2079 //
2080 //=================================================================================================
2081 
2082 //*************************************************************************************************
2084 template< typename VT, bool TF >
2085 struct SubvectorExprTrait< SparseSubvector<VT,TF> >
2086 {
2087  typedef SparseSubvector<VT,TF> Type;
2088 };
2090 //*************************************************************************************************
2091 
2092 
2093 //*************************************************************************************************
2095 template< typename VT, bool TF >
2096 struct SubvectorExprTrait< const SparseSubvector<VT,TF> >
2097 {
2098  typedef SparseSubvector<VT,TF> Type;
2099 };
2101 //*************************************************************************************************
2102 
2103 
2104 //*************************************************************************************************
2106 template< typename VT, bool TF >
2107 struct SubvectorExprTrait< volatile SparseSubvector<VT,TF> >
2108 {
2109  typedef SparseSubvector<VT,TF> Type;
2110 };
2112 //*************************************************************************************************
2113 
2114 
2115 //*************************************************************************************************
2117 template< typename VT, bool TF >
2118 struct SubvectorExprTrait< const volatile SparseSubvector<VT,TF> >
2119 {
2120  typedef SparseSubvector<VT,TF> Type;
2121 };
2123 //*************************************************************************************************
2124 
2125 } // namespace blaze
2126 
2127 #endif
Constraint on the data type.
Pointer difference type of the Blaze library.
ReferenceType value() const
Access to the current value of the sparse subvector element.
Definition: SparseSubvector.h:468
View on a specific subvector of a sparse vector.The SparseSubvector template represents a view on a s...
Definition: Forward.h:54
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
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
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
PointerType pointer
Pointer return type.
Definition: SparseSubvector.h:509
Header file for the subtraction trait.
SelectType< useConst, ConstReference, typename VT::Reference >::Type Reference
Reference to a non-constant subvector value.
Definition: SparseSubvector.h:354
Header file for the SparseVector base class.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SparseSubvector.h:504
Header file for the View base class.
SelectType< returnConst, const ElementType &, ElementType & >::Type ReferenceType
Return type of the value member function.
Definition: SparseSubvector.h:378
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
PointerType operator->() const
Direct access to the current sparse subvector element.
Definition: SparseSubvector.h:585
SubvectorTrait< VT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseSubvector.h:344
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
SubvectorIterator(IteratorType pos, size_t offset)
Constructor for the SubvectorIterator class.
Definition: SparseSubvector.h:529
size_t capacity() const
Returns the maximum capacity of the sparse subvector.
Definition: SparseSubvector.h:1271
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: SparseSubvector.h:1540
Iterator begin()
Returns an iterator to the first element of the subvector.
Definition: SparseSubvector.h:856
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SparseSubvector.h:500
Header file for the IsRowVector type trait.
bool operator!=(const SubvectorIterator< VectorType2, IteratorType2 > &rhs) const
Inequality comparison between two SubvectorIterator objects.
Definition: SparseSubvector.h:609
void assign(const DenseVector< VT2, TF > &rhs)
Default implementation of the assignment of a dense vector.
Definition: SparseSubvector.h:1674
Header file for the IsTransExpr type trait class.
#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
Operand vector_
The sparse vector containing the subvector.
Definition: SparseSubvector.h:747
Header file for the RequiresEvaluation type trait.
void reserve(size_t n)
Setting the minimum capacity of the sparse subvector.
Definition: SparseSubvector.h:1393
const size_t offset_
The offset of the subvector within the sparse vector.
Definition: SparseSubvector.h:748
SubvectorElement & operator=(const T &v)
Assignment to the accessed sparse subvector element.
Definition: SparseSubvector.h:399
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
SubvectorIterator & operator++()
Pre-increment operator.
Definition: SparseSubvector.h:552
SubvectorIterator< const VT, typename VT::ConstIterator > ConstIterator
Iterator over constant elements.
Definition: SparseSubvector.h:642
size_t nonZeros() const
Returns the number of non-zero elements in the subvector.
Definition: SparseSubvector.h:1287
IteratorType pos_
Iterator to the current position within the sparse subvector.
Definition: SparseSubvector.h:485
ConstIterator cend() const
Returns an iterator just past the last element of the subvector.
Definition: SparseSubvector.h:951
Base template for the SubvectorTrait class.
Definition: SubvectorTrait.h:122
SubvectorElement & operator+=(const T &v)
Addition assignment to the accessed sparse subvector element.
Definition: SparseSubvector.h:411
SubvectorElement & operator*=(const T &v)
Multiplication assignment to the accessed sparse subvector element.
Definition: SparseSubvector.h:435
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseSubvector.h:345
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: SparseSubvector.h:1498
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
Iterator end()
Returns an iterator just past the last element of the subvector.
Definition: SparseSubvector.h:913
ReferenceType operator*() const
Direct access to the current sparse subvector element.
Definition: SparseSubvector.h:575
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.
Header file for the multiplication trait.
ValueType ReferenceType
Reference return type.
Definition: SparseSubvector.h:503
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
SubvectorIterator()
Default constructor for the SubvectorIterator class.
Definition: SparseSubvector.h:517
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
Header file for the Or class template.
size_t offset_
The offset of the subvector within the sparse vector.
Definition: SparseSubvector.h:628
SparseSubvector(VT &vector, size_t index, size_t n)
The constructor for SparseSubvector.
Definition: SparseSubvector.h:794
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
Access proxy for a specific element of the sparse subvector.
Definition: SparseSubvector.h:362
void erase(size_t index)
Erasing an element from the sparse subvector.
Definition: SparseSubvector.h:1340
Iterator find(size_t index)
Searches for a specific subvector element.
Definition: SparseSubvector.h:1445
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:79
Constraint on the data type.
Header file for the SparseElement base class.
Constraint on the data type.
Constraint on the data type.
const SubvectorElement * operator->() const
Direct access to the sparse subvector element at the current iterator position.
Definition: SparseSubvector.h:458
bool isAliased(const Other *alias) const
Returns whether the sparse subvector is aliased with the given address alias.
Definition: SparseSubvector.h:1653
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:94
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
Constraint on the data type.
Header file for the SelectType class template.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2377
Header file for the EnableIf class template.
const SparseSubvector & CompositeType
Data type for composite expression templates.
Definition: SparseSubvector.h:348
DifferenceType operator-(const SubvectorIterator &rhs) const
Calculating the number of elements between two subvector iterators.
Definition: SparseSubvector.h:620
Header file for the IsNumeric type trait.
Reference operator[](size_t index)
Subscript operator for the direct access to the subvector elements.
Definition: SparseSubvector.h:822
SelectType< IsExpression< VT >::value, VT, VT & >::Type Operand
Composite data type of the dense vector expression.
Definition: SparseSubvector.h:327
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2374
Header file for the IsConst type trait.
void reset()
Reset to the default initial values.
Definition: SparseSubvector.h:1301
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:141
Base template for the MultTrait class.
Definition: MultTrait.h:141
Header file for the addition trait.
Header file for the division trait.
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
size_t index() const
Access to the current index of the sparse element.
Definition: SparseSubvector.h:478
Iterator insert(size_t index, const ElementType &value)
Inserting an element into the sparse subvector.
Definition: SparseSubvector.h:1323
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
size_t offset_
Offset within the according sparse vector.
Definition: SparseSubvector.h:486
SubvectorElement(IteratorType pos, size_t offset)
Constructor for the SubvectorElement class.
Definition: SparseSubvector.h:387
void addAssign(const DenseVector< VT2, TF > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: SparseSubvector.h:1730
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
SparseSubvector< VT, TF > This
Type of this SparseSubvector instance.
Definition: SparseSubvector.h:343
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2378
DifferenceType difference_type
Difference between two iterators.
Definition: SparseSubvector.h:511
Header file for the isDefault shim.
size_t size() const
Returns the size/dimension of the sparse subvector.
Definition: SparseSubvector.h:1257
SelectType< useConst, ConstIterator, SubvectorIterator< VT, typename VT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: SparseSubvector.h:645
SubvectorElement & operator/=(const T &v)
Division assignment to the accessed sparse subvector element.
Definition: SparseSubvector.h:447
Base class for all sparse element types.The SparseElement class is the base class for all sparse elem...
Definition: SparseElement.h:57
#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
ReferenceType reference
Reference return type.
Definition: SparseSubvector.h:510
VT VectorType
Type of the vector.
Definition: Vector.h:72
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
void append(size_t index, const ElementType &value, bool check=false)
Appending an element to the sparse subvector.
Definition: SparseSubvector.h:1602
Base template for the DivTrait class.
Definition: DivTrait.h:141
ValueType value_type
Type of the underlying elements.
Definition: SparseSubvector.h:508
SubvectorIterator(const SubvectorIterator< VectorType2, IteratorType2 > &it)
Conversion constructor from different SubvectorIterator instances.
Definition: SparseSubvector.h:541
bool canAlias(const Other *alias) const
Returns whether the sparse subvector can alias with the given address alias.
Definition: SparseSubvector.h:1633
#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
VT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseSubvector.h:347
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:147
SubvectorElement & operator-=(const T &v)
Subtraction assignment to the accessed sparse subvector element.
Definition: SparseSubvector.h:423
Header file for the IsComputation type trait class.
SparseSubvector & operator=(const SparseSubvector &rhs)
Copy assignment operator for SparseSubvector.
Definition: SparseSubvector.h:981
Iterator over the elements of the sparse subvector.
Definition: SparseSubvector.h:496
void subAssign(const DenseVector< VT2, TF > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: SparseSubvector.h:1792
IteratorType pos_
Iterator to the current sparse element.
Definition: SparseSubvector.h:627
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
Header file for basic type definitions.
Header file for the SubvectorExprTrait class template.
const SubvectorIterator operator++(int)
Post-increment operator.
Definition: SparseSubvector.h:563
Base template for the SubTrait class.
Definition: SubTrait.h:141
ConstIterator cbegin() const
Returns an iterator to the first element of the subvector.
Definition: SparseSubvector.h:894
VT::ElementType ElementType
Type of the subvector elements.
Definition: SparseSubvector.h:346
bool operator==(const SubvectorIterator< VectorType2, IteratorType2 > &rhs) const
Equality comparison between two SubvectorIterator objects.
Definition: SparseSubvector.h:597
SubvectorElement< VectorType, IteratorType > ValueType
Type of the underlying elements.
Definition: SparseSubvector.h:501
IteratorCategory iterator_category
The iterator category.
Definition: SparseSubvector.h:507
#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
VT::ConstReference ConstReference
Reference to a constant subvector value.
Definition: SparseSubvector.h:351
#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
Header file for the IsExpression type trait class.
const size_t size_
The size of the subvector.
Definition: SparseSubvector.h:749
Header file for the FunctionTrace class.
ValueType PointerType
Pointer return type.
Definition: SparseSubvector.h:502